Forum OpenACS Q&A: Re: Some thoughts on OpenACS caching

Collapse
Posted by Gustaf Neumann on

I particularly like the -cache_keys parameter available

Well, the db_interface with "-cache_key" iis not a recommended interface, since this does not scale and leads to many locks. Flushing of this cache is brute-force or not happening at all. In the sketched case - as you noted -, the cache has to be flushed (in the full cluster) whenever a new package is enabled (or installed) or disabled.

If you do not care about getting proper results in these situations, one can use the version below on oacs-5-10, which will be a lock free cache (not flushed as well).

one proc that I noticed gets called a lot ...

Why is apm_get_installed_versions gets called a lot on your site. On stock instances, this is only called by the package installer...

-g

  ad_proc -public apm_get_installed_versions {
     -array:required
  } {
     Sets the current installed version of packages installed on this system
     in an array keyed by package_key.
     
     @param array Name of array in caller's namespace where you want this set
 }  {
     upvar 1 $array installed_version
 
     array set installed_version [acs::per_thread_cache eval -key acs-tcl-apm_get_installed_versions {
        db_list_of_lists -cache_key installed_packages installed_packages { 
            select package_key, version_name
            from apm_package_versions
            where  enabled_p = 't'
        }
    }]
  }
Collapse
Posted by Andrew Piskorski on
Wait, so using db_multirow with -cache_key is not recommended? In that case, what is the recommended scaleable way to cache the results from db_* API calls?

I'd already noticed that the DB API caching, although very handy, has some surprising limitations. In particular, I want to report how old a particular cached result is. OpenACS does not store that info at all, so I stored it myself in an ancillary nsv. But this isn't the best solution, because if the cache is flushed in the background, my nsv storing the cache create time does not know, and gets out of sync.

Also, in the log when NaviServer starts up, my OpenACS installation says it's "Using ns_cache based on NX 2.4.0". That comes from NaviServer's tcl/aolserver-openacs.tcl file, which it describes in a comment as a, "Minimal ns_cache implementation based on NX".

So this NX-based stuff is a backwards compatibility wrapper for old AOLserver ns_cache calls? And OpenACS still uses those old AOLserver-style calls, instead of the full ns_cache_* stuff built into NaviServer? Which cache API am I best off using for my own work going forward?