Ard Schrijvers wrote:
Strictly speaking, you don't need access to the eviction policy itself - but only some exposed method on Store, something like purgeLastElementAccordingToEvictionPolicy -- can't they add something like that?

I of course did ask this, because this is obviously the way to go:
http://sourceforge.net/mailarchive/forum.php?thread_name=A955EA1F8FE31749AEC8C998082F6C7CD6E71E%40hai01.hippo.local&forum_name=ehcache-list

summarizing Greg: "There is real way to plug into the eviction mechanism from 
outside."

I had a glance at LfuMemoryStore (extends MemoryStore) and found out that their LFU policy kicks least frequently used element out of small subset of *random* elements out of the memory store... It's possible though to modify it to evict LFU element on request.

http://ehcache.svn.sourceforge.net/svnroot/ehcache/trunk/core/src/main/java/net/sf/ehcache/store/LfuMemoryStore.java

LruMemoryStore uses LinkedHashMap which, if I read it correctly, can return LRU element using map.values().next(), which then can be kicked out.

http://ehcache.svn.sourceforge.net/svnroot/ehcache/trunk/core/src/main/java/net/sf/ehcache/store/LruMemoryStore.java


So evict() can be implemented on MemoryStore, from what I see. Both of these store implementations though are completely synchronized and would perform worse than MRUBucketMap.

Vadim

Reply via email to