简体中文
Fx.cache
约 579 字大约 2 分钟
2026-01-09
目录
摘要
本文档的概要说明如下:
1. getDefaultCache DefaultCache
Fx.cache.getDefaultCache()
Groovy 举例
Cache cache = Fx.cache.getDefaultCache()
log.info(cache.get("key1"))
//put单位为秒,1~172800有效
cache.put("key1", 1234, 5)
log.info(cache.contains("key1"))
Integer value = (Integer) cache.get("key1")
log.info(value)
log.info(cache.inc("key1"))
if(cache.remove("key1")) {
log.info("remove success!")
}
log.info(cache.get("key1"))参考对象
- 参考Cache
注意事项
- 限制
- key字符串最大长度256
- value字符串最大长度1M
- 最大失效时间48h
- 单位秒
参考类 com.fxiaoke.functions.interfaces.Cache
字段说明
| 参数名称 | object | 描述 |
|---|
1. contains 缓存key是否存在
Cache.contains()
负责人:斯作益seth
2. put 插入键值对
Cache.put()
负责人:斯作益seth
3. get 不推荐使用,通过键获取值,key不存在返回null,返回结果是Object,需要根据需求转换类型 as String / as Integer
Cache.get()
负责人:斯作益seth
4. getString 通过键获取值,返回结果类型是String
Cache.getString()
负责人:斯作益seth
5. getInteger 通过键获取值,返回结果类型是Integer
Cache.getInteger()
负责人:斯作益seth
6. getLong 通过键获取值,返回结果类型是Long
Cache.getLong()
负责人:斯作益seth
7. remove 删除缓存
Cache.remove()
负责人:斯作益seth
8. inc 对数字key加一(value为字符串不支持)
Cache.inc()
负责人:斯作益seth
9. dec 对数字key减一(value为字符串不支持)
Cache.dec()
负责人:斯作益seth
版本记录
| 版本 | 日期 | 变更内容 | 负责人 |
|---|---|---|---|
| v1.0 | 2026-05-19 | 初始版本 |
背景说明
本文档详细描述 Fx.cache 的相关接口功能和使用方法,帮助开发者快速集成相关能力。
适用场景
具体适用场景由实际业务需求决定,开发者可根据需要选择相应的接口进行集成。
前置条件
- 已接入纷享销客开放平台
- 已完成应用授权与配置
- 了解相关业务领域基础知识
操作步骤
具体操作步骤请参考各接口的详细说明。
注意事项
- 调用接口前请确保满足前置条件
- 注意接口调用频率限制
- 异常情况请参考错误码说明进行处理
兼容性说明:当前版本暂无可用的废弃或兼容性说明。
