我可以连接LoadingCache
一个@Cacheable
方法。
我需要 GuavaCache 来支持 refreshAfterWrite
return new GuavaCache("cacheName", CacheBuilder.newBuilder()
.maximumSize(maxSize)
.expireAfterWrite(expireAfterWriteInSeconds, TimeUnit.SECONDS)
.ticker(ticker)
.build());
至
return CacheBuilder.newBuilder()
.maximumSize(maxSize)
.refreshAfterWrite(refreshAfterWriteInSeconds, TimeUnit.SECONDS)
.build(
new CacheLoader<Integer, List<Type>>() {
@Override
public List<Type> load(Integer id) {
return service.getServiceItem(id);
}
}
);
}
但我不明白如何将它LoadingCache
与 Spring Cache 声明联系起来@Cacheable("cacheName")