Forum OpenACS Development: Caching methods in OpenACS, use which?
- Use an ad hoc nsv or ns_cache.
- The ad_parameter_cache stuff.
- Don Baccus's db_* API caching, which I think was merged into CVS in Feb. 2006. Are there more? (E.g., perhaps XOTcl adds something else?) It'd probably be useful to have a list of all of them in one place. Which methods are now recommended?
- 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.
I tend to either use query caching directly, or ns_cache eval where I want to cache the result of a series of calculations. I find util_memoize annoying, myself, and I avoid using xotcl in my own custom sites because even fewer people are fluent in xotcl than are fluent in tcl, a downside if a stranger has to come in to work on one of my client sites.