alibaba / jetcache

JetCache is a Java cache framework.
Apache License 2.0
5.14k stars 1.06k forks source link

@CreateCache注解的缓存配置自动刷新,不会自动跑loader方法 #163

Closed wtjperi2003 closed 6 years ago

wtjperi2003 commented 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);

areyouok commented 6 years ago

要调用小写的get类的方法才会触发自动刷新,大写的方法只访问缓存,不会附加loader和自动刷新。