Re: LRU Cache using JE -
08-31-2006
, 07:14 PM
Hello Mark,
Thank you for your great advice on how to determine the database size
using sequences. I can understand how it wouldn't be exact, as records
may be updated or removed, thus creating holes in the sequence
elements, but I think it gives a close enough approximation for my
caching module. Your technique also provides great performance.
The module works as a FIFO cache. Elements get a sequence number when
they are inserted or updated, i.e. whenever StoredMap.put is called.
When the cache is determined to be over its size limit, the cache
starts removing entries in the order of their sequence numbers.
Basically, it works exactly like your suggestion in the previous post.
This isn't quite the LRU cache that I originally hoped for, but I
cannot see a way to make the cache LRU without performing a database
write every time an element is retrieved via StoredMap.get. For the
applications that this module will be used in, that seems like more
overhead than it's worth.
Thanks again for all of your help. It's very much appreciated.
Patrick |