[Zope] How to keep an object in the zodb cache?
Gregory Popovitch
greg@gpy.com
Thu, 24 Jan 2002 12:45:51 -0500
Hi,
I am writing a product which loads a large python structure
object from disk. I don't wish to store this structure in the Zope
Zodb, so I load it in a variable prefixed with _v_.
The code looks like:
class myproduct(SimpleItem.SimpleItem):
def __init__(self, id, title):
" initializes a new instance of a myproduct"
self.id = id
self.title = title
self._v_store = None
def load(self):
" load store into memory "
import mystore
if not hasattr(self, '_v_store') or not self._v_store:
print "loading store"
self._v_store = mystore.LoadStore(self.title)
The function self.load() is called from each URL method to ensure
that the store is loaded.
My problem is that after some inactivity in the web server, I can see
that the store is reloaded when a web page is requested, and it takes
some time.
I assume that the object self._v_store has been flushed from the zodb cache
and discarded.
How can I prevent self._v_store from ever beeing flushed from the cache?
Any idea?
Thanks,
Gregory Popovitch