cached backed or self-emptying map

W

Wendy Smoak

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
 
R

Robert

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.
 
W

Wendy Smoak

Robert said:
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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top