**
Maven依赖
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-redis</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>com.alicp.jetcache</groupId>
<artifactId>jetcache-starter-redis</artifactId>
<version>2.6.0</version>
</dependency>
yaml配置
参考源码:
com.alicp.jetcache.autoconfigure.JetCacheProperties
com.alicp.jetcache.autoconfigure.AbstractCacheAutoInit
com.alicp.jetcache.autoconfigure.RedisAutoConfiguration.RedisAutoInit
jetcache:
areaInCacheName: false
remote:
default:
type: redis
keyConvertor: fastjson
poolConfig:
minIdle: 10
maxIdle: 300
maxTotal: 300
password: 123456
database: 2
sentinels: xxxxx
masterName: REDIS
Java代码
//缓存
@Cached(name = CENTER_DATA_CACHE_KEY, expire = 60 * 60 * 24 * 2, cacheNullValue = true)
public DmEffBillYear getData(BillDataReq req) {
reture null;
}
//刷新缓存
@CacheUpdate(name = CENTER_DATA_CACHE_KEY, value = "#result")
@Override
public DmEffBillYear freshData(BillDataReq req) {
return getData(req);
}
**