Hi,

I've checked the cache implementation from excalibur scratchpad
and notice that LRUCachePolicy use the ListCachePolicy LinkedList
to perform the LRU mecanism.

To have a LRU 'hit' effect, it removes the object from the list
and put it at the top.
What if the list is really huge? I mean, to perform the remove it
has to scan the whole list, since it doesn't have an index (or
I'm wrong)? 

I would suggest having another approach using a logical clock
value and 'time' hashmap.

Something like:
When a 'hit' is called, it gets the current object and set its
'value' to the current logical time.
To remove the oldest, it gets the oldest value in the time map.

To be really honest, this approach is not necessarily the best:
the remove case is slower that the linked list one, but the 'hit'
could be faster. Now it depends on the hit/remove ratio. But I
guess in an LRU cache, you should have a maximum of 'hit' call.


Regards

-- 
mailto:[EMAIL PROTECTED] -
http://sourceforge.net/projects/jabaserver

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to