cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <va...@reverycodes.com>
Subject Re: StoreJanitor
Date Thu, 05 Apr 2007 15:11:35 GMT
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

Mime
View raw message