Jetcache+SpringBoot配置

**

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);
}

Jetcache wiki

Jetcache Jedis

Jetcache lettuce

Jetcache Springboot

**

上一篇:在SpringBoot中开发RestAPI应用


下一篇:解决:NACOS 异常com.alibaba.nacos.api.exception.NacosException: failed to req API:/api//nacos/v1/ns/insta