Commit e3c65066 authored by Jim Fulton's avatar Jim Fulton

Added cache management methods so that apps that want to move objects

out of memory can force aggressive cache behavior:

  cacheGC() -- do an incremental GC

  cacheFullSweep([dt]) -- Make a pass through objects in the cache
     removing unreferenced objects and, if dt > 0, deactivating
     objects accessed more than dt seconds ago.

  cacheMinimize([dt]) -- Make multiple passes through objects in the cache
     removing unreferenced objects and, if dt > 0, deactivating
     objects accessed more than dt seconds ago. Keep making passes
     until the cache size doesn;t change.
parent 59243da3
......@@ -84,8 +84,8 @@
##############################################################################
"""Database connection support
$Id: Connection.py,v 1.24 1999/09/15 00:36:32 jim Exp $"""
__version__='$Revision: 1.24 $'[11:-2]
$Id: Connection.py,v 1.25 1999/09/15 16:10:33 jim Exp $"""
__version__='$Revision: 1.25 $'[11:-2]
from cPickleCache import PickleCache
from POSException import ConflictError, ExportError
......@@ -120,7 +120,7 @@ class Connection(ExportImport.ExportImport):
"""Create a new Connection"""
self._version=version
self._cache=cache=PickleCache(self, cache_size, cache_deactivate_after)
self._incrgc=cache.incrgc
self._incrgc=self.cacheGC=cache.incrgc
self._invalidated=d={}
self._invalid=d.has_key
self._committed=[]
......@@ -130,6 +130,8 @@ class Connection(ExportImport.ExportImport):
except: pass
try: del self._incrgc
except: pass
try: del self.cacheGC
except: pass
def __getitem__(self, oid,
tt=type(()), ct=type(HelperClass)):
......@@ -222,6 +224,9 @@ class Connection(ExportImport.ExportImport):
"""
self._cache.invalidate(object._p_oid)
def cacheFullSweep(self, dt=0): self._cache.full_sweep(dt)
def cacheMinimize(self, dt=0): self._cache.minimize(dt)
def close(self):
self._incrgc()
db=self._db
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment