springboot集成阿里开源多级缓存JetCache

# JetCache > https://blog.csdn.net/sinat_32366329/article/details/80260944 ## 依赖 ```$xslt com.alicp.jetcache jetcache-starter-redis-lettuce 2.5.9 ``` ## 配置 ```$xslt @Configuration @EnableMethodCache(basePackages = "input your package name!!!") @EnableCreateCacheAnnotation public class CacheConfig { } jetcache: statIntervalMinutes: 15 areaInCacheName: false hiddenPackages: com.alibaba local: default: type: caffeine limit: 100 keyConvertor: fastjson expireAfterWriteInMillis: 100000 remote: default: type: redis.lettuce keyConvertor: fastjson valueEncoder: kryo valueDecoder: kryo uri: redis://XXX@host:6379/6 ``` ## 使用 ```$xslt public interface UserService { @Cached(name="userCache.", key="#userId", expire = 3600 ,cacheType = CacheType.BOTH) User getUserById(long userId); @CacheUpdate(name="userCache.", key="#user.userId", value="#user") void updateUser(User user); @CacheInvalidate(name="userCache.", key="#userId") void deleteUser(long userId); } ```

你可能感兴趣的:(springboot集成阿里开源多级缓存JetCache)