Forum OpenACS Development: Caching: db_cache_pool vs. util_memoize
I have the slight feeling that a lot of code where we are using util_memoize for at the moment could be refactored using db_cache_pool, but I would like to write up a small guideline on when to do chaching and which kind of caching, so hopefully you (and others) can help out
Use the db cache feature to cache query results, use ns_cache if you want to cache the result of something computed in Tcl.
The tricky bit with the db cache pool stuff is to construct a useful key for maintaining cache contents.
But that's true with util_memoize as well, cache coherency is a problem no matter what one does.
Additionally I am wondering, especially due to the cluster situation, if we should not have a wrapper for ns_cache, which allows us to flush the cache across the cluster if needed.
My assumption is that we will probably need a wrapper for ns_cache, which behaves similar to util_memoize with regards to clusters (and the flush-memoized-statement.tcl file), but offers more functionality and if it is only the name of the cache to use.
Last but not least I am wondering where we should provide the functionality to set the size of the caches? At the moment this is done in the Kernel parameters, so should each new cache have it's own setting there? How about default timeouts?