[Zope] Python, persistent objects and caching

Dieter Maurer dieter@handshake.de
Thu, 7 Sep 2000 22:39:59 +0200 (CEST)


Brian Lloyd writes:
 > Soren Rough writes
 > > ... application level cache ...
 > > ... application objects flushed (including cache)

 > One approach would be to cache your data in the module's 
 > namespace. For ex:
 > 
 > mycache={}
 > 
 > class MyClassThatKeepsGoingAway:
 >   ...
 >   def get_data(self, id):
 >     if mycache.has_key(id):
 >       return mycache[id]
 >     else:
 >       ...
 > 
 > 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 can use a "SharedResource" for this:

	URL:http://www.dieter.handshake.de/pyprojects/zope/SharedResource.html


Dieter