我已经有一个系统,它使用 spring 的缓存抽象 + EhCache 实现缓存解决方案。但是现在,我需要将 EhCache 切换为其他能够为我提供分布式功能的解决方案。我发现 JCS ( java Caching System ) 适合我的问题。但是,我还没有设法找到一种将 Spring 缓存抽象与 JCS 一起使用的方法。你们中的任何人都知道如何将 Spring 缓存抽象与 JCS 一起使用吗?如果是这样,我该怎么做?
@Bean(destroyMethod = "shutdown")
public net.sf.ehcache.CacheManager ehCacheManager() {
net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
DiskStoreConfiguration store = new DiskStoreConfiguration();
store.setPath(
diskDirectory);
config.addDiskStore(store);
CacheConfiguration cacheConfiguration = new CacheConfiguration();
cacheConfiguration.setName("disk");
cacheConfiguration.maxEntriesLocalHeap(1);
cacheConfiguration.setTimeToLiveSeconds(Integer.parseInt(cacheTime));
cacheConfiguration.setMemoryStoreEvictionPolicy("LRU");
cacheConfiguration.maxBytesLocalDisk(Long.parseLong(diskSize), MemoryUnit.GIGABYTES);
PersistenceConfiguration perCache = new PersistenceConfiguration();
perCache.strategy(Strategy.LOCALTEMPSWAP);
cacheConfiguration.addPersistence(perCache);
config.addCache(cacheConfiguration);
return net.sf.ehcache.CacheManager.newInstance(config);
}
我的目标是找到一个像上面那样工作的 CacheManager 类,因此,能够使用 @cacheble、@key 等注释。
谢谢!!