cache entry lifetime-exceeded-listener?

"Martin Heitz" <[email protected]>
Newsgroups gmane.comp.java.open-symphony.os-cache
Message-ID <[email protected]>
Hi,

I would like to solve the following problem with OSCache (in a J2EE
environment):
My cache entries are all implementing an interface which allows to
determine their lifetime.
With help of an own EntryRefreshPolicy I am letting OSCache check this
lifetime on cxache access.

But what I need in addition is a way to peridically clean the cache
(where clean means to remove all outdate entries) and - on removal of
those outdated entries - to call some algorithm which reacts on those
entries being outdated (reaction does not necessarily mean to update the
cache entries, therefore no hardcoded logics but calling a sort of
listener will be needed).

I implemented my own cache algorithm (extension of
AbstractConcurrentReadCache) and manage to periodically trigger the
cleaning by abusing the setMaxEntries method (which is called by the
Cache.setCapacity class directly and is therefore accessible without
additional tricks + it is not needed by my algorithm, because it has an
unlimited cache size). This already is a bad design - but I could not
find a nicer way to call extended functionality in my cache algorithm
(except of reflection).

Is there a nice way to get access to the cache algorithm map? It would
be enough for me, if it were protected instead of private, then I could
extend the Cache class, cast the the Cache.cacheMap variable to my
algorithm and execute whatever I need. But I see the drawback, that then
the validity of the entries in the map cannot be guaranteed any more
(which b.t.w. is also true if modifying the map from own algorithm
classes).

Best regards from Black Forest, Germany,
	Mattin

Martin Heitz
Distributed Network Accounting Team

Elsag Solutions AG
Roggenbachstr. 1
D-78050 Villingen-Schwenningen
Germany
http://www.elsag-solutions.com
Tel: +49-(0)7721-9175-595
Fax: +49-(0)7721-9175-800
 


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id56&alloc_id438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.