[Zope-PAS] Re: RFC: PAS caching

Tres Seaver tseaver at zope.com
Fri Oct 8 10:40:11 EDT 2004

Jens Vagelpohl wrote:
> Hi guys,
> I'm going to work on caching for PAS and have thought about a couple 
> different architectural models to do so. I've come to a model I 
> personally like and wouldn't mind some comments.
> Basically, I am proposing an architecture that works a little bit like 
> ZCacheable in that you instantiate cache managers and associate objects 
> (in this case plugins) with them. Obviously there are only a few plugin 
> types where it makes sense to cache anything. Since the "cacheable" 
> plugins have varying interfaces there would be specific cache manager 
> objects for each of them, and only the appropriate plugin can be 
> associated with them.

I'm not sure why you want this part.  For instance, why not just have a 
single RAM cache manager, and then associate the plugins with it?  Each 
one of the plugins is responsible for identifying the keys, and 
therefore could use themselves as the 'ob', e.g.::

   cached = self._cache.ZCache_get(ob==self,
   if cached is not None:
      return cached
   # ... do the work
   self._cache.ZCache_set(ob=self, data=result,
   return result

> The plugins would cache based on keys that reflect the arguments to the 
> given method that is used to retrieve data and allow to set parameters 
> such as cache duration and knobs to invalidate the cache.
> The caches require some cooperation from the plugins so that the methods 
> that provide cacheable data would try to locate and consult an 
> appropriate cache first, just like index_html in some basic OFS types 
> now consults ZCache_get before computing a result. The interfaces itself 
> would not be affected, just the implementations (which I would handle 
> myself, too).
> What do you think?

The other option is to have the PAS serve as the "cache manager" for its 
plugins;  the potential win is that the PAS might be able to avoid even 
consulting the plugins if it knew that a cached value was available. 
The current implementation at least contemplates this, although it is 
mostly commented out.

Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com

More information about the Zope-PAS mailing list