一、添加相应坐标
二、yml文件配置
#默认远程配置,只配置本地也可以
jetcache:
#本地配置
statIntervalMinutes: 1
local:
default:
type: linkedhashmap
keyConvertor: fastjson
#远程配置
remote:
default:
type: redis
keyConvertor: fastjson
host: localhost
port: 6379
valueEncode: java
valueDecode: java
#必要属性poolconfig
poolConfig:
maxTotal: 50
三、使用方法
1.启动类加属性
basePackages中填你想要启用缓存方法所在的包名。
2.定义jetCache
@CreateCache(name = "jetCache",expire = 10,timeUnit = TimeUnit.SECONDS,cacheType = CacheType.LOCAL)
private Cache<String,String> jetCache;
expire:缓存存在时长
timeUnit:时间类型
cacheType:缓存类型。(本地,远程,两者)
3.缓存使用
设置缓存
获取缓存