Closed wtjperi2003 closed 6 years ago
文档看下面连接的最底部 https://github.com/alibaba/jetcache/wiki/AdvancedCacheAPI_CN 我项目里几乎一模一样的,在loader方法里打印key,始终没有打印出来 `@CreateCache(name=Constant.Redis.YED_ADMIN_CACHE,expire = 3600) private Cache<String,Admin> adminCache; @PostConstruct public void init(){ System.out.println("---------------------------------"); RefreshPolicy policy = RefreshPolicy.newPolicy(5, TimeUnit.SECONDS).stopRefreshAfterLastAccess(30, TimeUnit.MINUTES); adminCache.config().setLoader(key -> { System.out.println(key+"===================key"); return new Admin(); }); adminCache.config().setRefreshPolicy(policy);
}`
另外在改类里另一个方法调用了 adminCache.PUT(exist.getId(), exist);
adminCache.PUT(exist.getId(), exist);
要调用小写的get类的方法才会触发自动刷新,大写的方法只访问缓存,不会附加loader和自动刷新。
文档看下面连接的最底部 https://github.com/alibaba/jetcache/wiki/AdvancedCacheAPI_CN 我项目里几乎一模一样的,在loader方法里打印key,始终没有打印出来 `@CreateCache(name=Constant.Redis.YED_ADMIN_CACHE,expire = 3600) private Cache<String,Admin> adminCache; @PostConstruct public void init(){ System.out.println("---------------------------------"); RefreshPolicy policy = RefreshPolicy.newPolicy(5, TimeUnit.SECONDS).stopRefreshAfterLastAccess(30, TimeUnit.MINUTES); adminCache.config().setLoader(key -> { System.out.println(key+"===================key"); return new Admin(); }); adminCache.config().setRefreshPolicy(policy);
另外在改类里另一个方法调用了
adminCache.PUT(exist.getId(), exist);