Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
457 views
in Technique[技术] by (71.8m points)

caching - When overFlowToDisk gets activated in EHCACHE?

I have some questions on "overflowToDisk" attribute of element?

1) I read at this URL that :

overflowToDisk sets whether element can overflow to disk when the memory store has reached the maximum limit.

"Memory" above refers JVM memory allocated for Java process running EHCACHE, or is there any parameter in to specify Cache memory size?

2) When the poces running EHCACHE terminates for some reason, whether this disk gets cleared and everything in cache gets vanished?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Elements start to overflow to the disk when you have more than maxElementsInMemory of them in the memory store. The following example creates a cache that stores 1000 elements in memory, and, if you need to store more, up to 10000 on disk:

<cache name="cacheName"
       maxElementsInMemory="1000"
       maxElementsOnDisk="10000"
       overflowToDisk="true"
       timeToIdleSeconds="..."
       timeToLiveSeconds="...">
</cache>

For the second question, have a look at the diskPersistent parameter. If it is set to true, Ehcache will keep your data stored on the disk when you stop the JVM. The following example demonstrates this:

<cache name="cacheName"
       maxElementsInMemory="1000"
       maxElementsOnDisk="10000"
       overflowToDisk="true"
       diskPersistent="true"
       timeToIdleSeconds="..."
       timeToLiveSeconds="...">
</cache>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...