我想在春天使用Echcache
mvc。因此对于此使用类似于此的java配置:Spring mvc Ehcache问题
public net.sf.ehcache.CacheManager ehCacheManager() {
net.sf.ehcache.config.Configuration config = new net.sf.ehcache.config.Configuration();
CacheConfiguration cacheConfig = new CacheConfiguration();
cacheConfig.setName("test");
cacheConfig.setMaxEntriesLocalHeap(0);
cacheConfig.setMaxEntriesLocalDisk(10);
cacheConfig.setTimeToLiveSeconds(500);
config.addCache(cacheConfig);
DiskStoreConfiguration diskStoreConfiguration = new DiskStoreConfiguration();
diskStoreConfiguration.setPath("C:/MyCache1");
config.addDiskStore(diskStoreConfiguration);
return net.sf.ehcache.CacheManager.newInstance(config);
}
并用于注解@cachable
用于高速缓存。它工作正常。但所有缓存的数据都保存在内存中。它只创建零大小的test.data
文件。现在我的问题是如何将缓存数据写入磁盘?
谢谢,我使用'config.persistence(新的PersistenceConfiguration()。strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP));'但不工作。 – ali
Strategy.LOCALTEMPSWAP仅用于内存中缓存。如果您想要基于磁盘文件,请使用Strategy.LOCALRESTARTABLE - 注意:LOCALRESTARTABLE持久性功能在企业版Ehcache中可用。 –
那么为什么我不使用弹簧提供程序'ehcache'它写入磁盘?我的意思是使用'ehcache'方法 – ali