2017-10-17 133 views
3

我正在使用ehcache将磁盘上的数据保留为JVM重新启动。由于数据非常大,我想尝试BigMemory Go产品。 但在他们的文档中,我没有发现任何提及的磁盘配置(最大大小,路径)。 用的Ehcache我的配置是这样的:如何为磁盘持久性配置BigMemory?

PersistentCacheManager persistentCacheManager = 
newCacheManagerBuilder() 
.with(persistence(new File("path_to_cache_dest")) 
.withCache("myType"), newCacheConfigurationBuilder(String.class, String.class, newResourcePoolsBuilder() 
.disk(2, MemoryUnit.GB, true)) 
.build(true); 

什么是BigMemory围棋等价?在BigMemory中处理磁盘持久性的对象是什么?代码示例会很棒。

+0

据我所知,ehcache没有大小限制。你的数据有多大? –

回答

2

BigMemory Go是基于Ehcache 2.x的商业产品。因此它与Ehcache 3.x无关,因为它使用不同的代码库和不同的API。

所以,你会需要配置了Ehcache x为磁盘持久性,然后运行与商业版本的配置,然后它将使用商用盘店:

new CacheManager(new Configuration() 
    .cache(new CacheConfiguration("aCache", 10000) 
     .persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.LOCALRESTARTABLE))  
     .maxBytesLocalDisk(2, MemoryUnit.GB) 
     .timeToLiveSeconds(1000) 
     .timeToLiveSeconds(360)) 
    .name("testDiskStoreSize") 
    .diskStore(new DiskStoreConfiguration().path("java.io.tmpdir/testDiskStoreSize"))); 

注意上面仍然会工作在如果您要用Strategy.LOCALTEMPSWAP替换Strategy.LOCALRESTARTABLE,请使用开源代码。您只会失去防撞重启能力,并使用不同的磁盘存储模式。