"- 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? ...
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.