[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Error in FAQ regarding diskPersistent?  XML
Forum Index -> Ehcache
Author Message
brianh

neo

Joined: 08/28/2009 15:14:49
Messages: 4
Offline

The FAQ (http://ehcache.sourceforge.net/documentation/faq.html) has this entry:
How do I get a memory only cache to persist to disk between VM restarts?
While disk persistence between restarts is a feature of the DiskStore only, you can get the same behaviour for a memory only cache by setting up a cache with maxElementsInMemory set to Integer.MAX_VALUE, 2147483647, overflowToDisk set to true and diskPersistent set to true.

But I have found this information to be inaccurate. For me, memory cache disk persistence works by setting the following configuration values:

1) maxElementsInMemory="1000" (or any value lower than Integer.MAX_VALUE)
2) overflowToDisk="false"
3) maxElementsOnDisk="1000" (same value as maxElementsInMemory)
4) diskPersistent="true"
5) clearOnFlush="false"
6) Also, I call flush() each time I put an element in the cache to update the disk backup.

Can anyone explain why the FAQ says what it says, but doesn't seem to work? Is there something wrong with the FAQ, or with me? =)
gluck

jedi

Joined: 09/15/2009 18:01:23
Messages: 118
Location: Brisbane, Australia
Offline

Yes, FAQ is inaccurate.

I have updated it. Also, you make a good point. flushing after each mutation is a good idea if you want to ensure you always get the cache contents back on restart.
brianh

neo

Joined: 08/28/2009 15:14:49
Messages: 4
Offline

Thank you. I am eager to see what the new info says, but the FAQ has not updated yet. When should one expect to see the changes published?
brianh

neo

Joined: 08/28/2009 15:14:49
Messages: 4
Offline

So now the FAQ says this:

"While disk persistence between restarts is a feature of the DiskStore only, you can get the same behaviour for a memory only cache by setting up a cache with maxElementsInMemory set to Integer.MAX_VALUE, 2147483647 and diskPersistent set to true.

You can manually call flush() to flush to disk. It is a good idea to set clearOnFlush to false so that the MemoryStore is not cleared each time. You can then call flush() to persist whenever you wish."

The key settings I believe are diskPersistent=true and clearOnFlush=false (and overflowToDisk=false, but that is set by default).

I'm still not sure though why the FAQ says you must set maxElementsInMemory to Integer.MAX_VALUE. I believe you can set this to any value as long as you also set maxElementsOnDisk to the same value. Setting the cache size to Integer.MAX_VALUE could potentially force a large memory footprint that might not be acceptable.
 
Forum Index -> Ehcache
Go to:   
Powered by JForum 2.1.7 © JForum Team