[Zope] Python, persistent objects and caching
Thu, 7 Sep 2000 09:39:35 -0400
> I'm developing a Python-based product that uses persistent objects in
> ZODB to store its configuration. No surprises there, but my product is
> also using volatile attributes to do a bit of caching of its own. The
> thing is, when ZODB takes a sweep every 60 seconds to flush it's own
> cache it will quite often flush my product as well, essentially
> rendering my 15 minute caching ineffective.
> If there a way I can prevent this from happening?
> Soren Roug
One approach would be to cache your data in the module's
namespace. For ex:
def get_data(self, id):
Note that my example is a little contrived, since using a module
variable means that you will have to implement this in a way that
is safe for a multi-threaded environment. You will also want to
make sure that your module-level cache doesn't grow forever and
take up a lot of memory.
Hope this helps!
Brian Lloyd (firstname.lastname@example.org)