Posted:
4-September-2008 23:33 Well, I guess it is when reading the docs, but not as useful as I had hoped.
I'm not sure what would be the best approach to distributed caching, but the first step I'm trying to take is implementing a basic cache in the first place. I'd like to apply a custom cache to just the results from one module while letting the system cache handle everything else. However, since a cache implementation is found by going up the call stack when a cache is set in a module then all subrequests must use that same cache implementation. So if I wanted to cache the output of my dpml pages differently (say, to a slower but persistent cache of disk-based files, or using slightly different cache semantics like using only the request and not the call stack as a key) using the built-in cache, it would end up trying to cache every resource request that is made in the creation of that page. Needless to say, this could adversely affect both performance and correctness.
The alternative I guess is to rewrite all requests in my module to be wrapped by a caching accessor that handles this explicitly, but then if I want to use the same caching logic (metadata, expiry, and so forth) I need to implement all that myself which seems, well, redundant.
A possible enhancement to address this is to add in a module private cache that would be used for requests within a module but not for subrequests to other modules. Looking at Cache.java I don't think this would be a complicated change (check for a module private cache before walking the superstack and only check for a inherited cache in the walk) but there may well be subtleties in the cache finding that are not immediately evident. |