I'm trying to cache objects that are expensive to load from the database,
but I need the 'visible' object to be a Map so I can use it with JSTL.
I set about extending AbstractMap and the 'get' method was easy, but I got
stuck on the 'entrySet' method. The cache I'm using does not expose its
underlying Map, which I understand... but I need that entrySet! The
developers seem interested in working on it, so maybe they'll come up with a
solution.
Meanwhile, does anyone know of a good Java-based object cache that can
answer the question "What's in the cache" at any point in time?
Alternately, I could live with a Map that empties itself at midnight. Or
something that I could schedule in Tomcat to replace a couple of context
attributes with empty maps. I'm open to suggestions...
Some code and notes as I work through this are posted here:
http://wiki.wendysmoak.com/cgi-bin/wiki.pl?WhirlyCache

Signature
Wendy Smoak
Robert - 29 Apr 2005 00:50 GMT
Maybe I don't understand your problem but why won't a wrapped HashMap
work? You just write the class to do the timing clean out at midnight.
I've used a Map of Maps at several companies I've worked for. Also
you may check out EHCache we use that here for our hibernate objects.
Wendy Smoak - 29 Apr 2005 01:09 GMT
> Maybe I don't understand your problem but why won't a wrapped HashMap
> work? You just write the class to do the timing clean out at midnight.
> I've used a Map of Maps at several companies I've worked for.
It probably would for the self-cleaning Map, that was a recent idea, and I
don't [yet] know how to write the timing part. I'm under the impression
that starting new threads in a Servlet Container environment is frowned
upon, so I want to make sure I don't break anything.
I would rather leave the cache size and expiration up to someone who knows
what they're doing... I'll check out EHCache, a quick look shows that it has
several 'getKeys' methods. Thanks!

Signature
Wendy