2017-10-17 78 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,請使用開源代碼。您只會失去防撞重啓能力,並使用不同的磁盤存儲模式。