Skip to main content
0 online
deanh77 Aug 8, 2005

"- One pattern I've seen is where the Cache is accessed by the "client", and if there is a cache miss, the Cache layer accesses the DAO layer and populates the Cache. What do you think about this? ...

deanh77 Aug 8, 2005

oh, and the main entrypoint is a class that represents a proprietary "SystemCache" (not bound to any particular tech). There is basically one method "get(Object key)". This class delegates to the...

iwz iwz ·

Ok, cool. This is basically the pattern we've started using based on this article. http://www.javaworld.com/javaworld/jw-05-2004/jw-0531-cache.html

So, the client should call the CacheManager, which should call the CacheLoader for that object, which should call the DAO.

If a particular object is not to be cached, it should just call the DAO directly.

deanh77 deanh77Founder ·

yeah, except I've created another "layer" I guess in the "SystemCache" object which owns a reference to the CacheManager and the CacheLoader.

this way your client only needs to call the following:

Object myObj = widgetCache.get("widget1"); (either returns the object, or null if either no object found in data source, or if an exception is thrown, therefore, it looks sort of like a read-only HashMap)

widgetCache was created previously somewhere as:

SystemCache widgetCache = new SystemCache(JCSCacheManager.getInstance(), WidgetCacheLoader.getInstance());

I'm using spring, so we don't create the SystemCache in this manner in our code, but this is the aproximate syntax.

Welcome Back to eZabel

It's been a while. Here's what's new.

eZabel Lore

A complete history of our community — stats, Hall of Fame, legendary threads, and more.

View the Lore →

Everything Preserved

All 225,969 pieces of content from 2000–2014 are here — forums, messages, journals, photos, polls, and events.

💎

Gems

Spot something you love — a legendary comment, a classic thread, a great photo? Log in and click the diamond icon to mark it as a Gem. Add a note about why it's special. The best stuff surfaces on the Gems page.