Forum OpenACS Development: Re: Caching methods in OpenACS, use which?

Posted by Gustaf Neumann on
There is no "offical" recommendation, but i can give a personal one:
- for the casual caching, use util_memoize (it is not the fastest solution, but has e.g. built-in cluster awareness)
- for applications managing a set of related data to be cached, use ns_cache. ns_cache has the advantage that it provides smaller granularity, so the memory bounds can be set for the related data, the statistics are from these etc. (btw, naviserver has improved ns_cache statistics). If it comes to mutex contention, smaller caches are better as well.

xotcl-core and xowiki use ns_cache for these reasons. For cluster-stuff, xotcl-core has ::xo::clusterwide, which can be used for various clusterwide tasks, such as flushing arbitrary ns_caches.

xotcl-core supports as well per-request caching (useful e.g. for multiple permission checks which should be performed only once per connection) which is flushed automatically after the request. This does not need cluster awareness etc. but is certainly not a general replacement for ns_cache.