How can I make Ehcache never evict from diskstore?

徘徊边缘 提交于 2019-12-08 09:09:19

问题


I'm trying to configure Ehcache (version 2.5) such that it never forgets items. Here is my initial attempt, but apparently Ehcache will try to protect me from myself by evicting if it runs out of space for the keys.

Is there any way for me to configure the Ehcache (the free version) to really store elements for as long as the application is running? If Ehcache might lose elements (without telling me!) then I can't really use it for my purposes. Note that I have orders of magnitude more heap space then I use in that other example; I just set it up that way to ensure it started writing to disk early on.


回答1:


Using pinning : see http://ehcache.org/documentation/configuration/data-life#pinning-data and use inCache pinning with the disk store. Though I don't really get what you expect ehcache to do here. If you want to avoid eviction at all cost and the maxBytesOnHeap seem like a bad idea. The whole point of specifying the maxBytesOnHeap is to protect you from OOME'ing. Using Gigs of heap might make it more sensible I guess... but basically, when using the DiskStore, you (and ehcache) have to account for the key set, which is held in memory... So having a maxBytesOnHeap > keySet's size would help keeping your hot set on heap, next to the entire key set. Hope this helps!



来源:https://stackoverflow.com/questions/8980467/how-can-i-make-ehcache-never-evict-from-diskstore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!