[Zope] Cacheing

Evan Simpson evan@4-am.com
Mon, 13 Sep 1999 14:15:30 -0500


Consider this scenario:

You want to cache a high-demand page for one minute or until new content is
added, whichever is *longer* (updates are frequent, and would defeat the
cache).  You create a ZCache object such that it will be published at the
desired URL, and you place the DTML Document which defines the page inside of
it (it can hold exactly one object).  You set the ZCache's minimum_time
property to 60 seconds and leave maximum_time blank.  In the object which
adds new content, you call the manage_reset method of the ZCache object.

Elsewhere in your site, you have an expensive, frequently called method whose
rendering should only change if one of its properties or its content is
edited.  You put it in a ZCache object, and also edit the ZCache object's
default manage_cacheTest method so that it checks and stores the modification
timestamp of the cached object.

A ZCache would act as a proxy for its contained object, storing the
last-rendered text as a volatile value.  Simple cache rules could be set via
properties, while more complicated rules could be implemented with
manage_reset, manage_resetForced, and manage_cacheTest.  manage_resetForced
would override rules, while manage_reset would respect them.
manage_cacheTest would have easy access to volatile storage.

Thoughts?