2015-10-20 26 views
0

我在我的服務器上使用ehcache作爲熱緩存。我希望它完全在內存中,只能寫入磁盤以進行持久化。從應用程序重新啓動時加載回來。ehcache在每次寫入時沖洗到磁盤

我看到ehcache幾乎在每個緩存中寫入磁盤。這裏是什麼文件說

Operation of a Cache where overflowToDisk is false and diskPersistent is true 

In this configuration case, the disk will be written on flush or shutdown. 
The next time the cache is started, the disk store will initialise but will not permit overflow from the 
MemoryStore. In all other respects it acts like a normal disk store. 

然而,當我檢查的/ mnt/ehcache的我看到它被寫入到各裝。爲什麼會發生這種情況?

這是我的緩存配置。

<diskStore path="/mnt/ehcache/" /> 

    <cache 
    name="feedLocalCache" 
    maxEntriesLocalHeap="2000000" 
    eternal="false" 
    timeToLiveSeconds="1800" 
    timeToIdleSeconds="0"   
    diskPersistent="true" 
    overflowToDisk="false" 
    memoryStoreEvictionPolicy="LFU" > 
    <bootstrapCacheLoaderFactory class="net.sf.ehcache.store.DiskStoreBootstrapCacheLoaderFactory" properties="bootstrapAsynchronously=true"/> 

回答

2

歸咎於文檔上已經過時。

由於Ehcache 2.6是最低層,在您的情況下也稱爲權限 - 磁盤 - 始終包含所有映射。這是爲了提高延遲的可預測性。

所以你看到的是預期的行爲。請注意,磁盤寫入是異步的,因此不會影響您的線程執行put操作 - 除非寫入太多以至寫入隊列達到其最大大小。

+0

我的服務器負載很重。我會說我正在做每秒接近2k的提升以及每秒至少5k的讀取。任何想法如何我可以提高我的表現?因爲當我進行一些分析時,放置和獲取被視爲熱點之一。 –