[Zope3-checkins] CVS: Zope3/lib/python/Persistence - Cache.py:1.3
Jeremy Hylton
jeremy@zope.com
Wed, 24 Jul 2002 18:51:58 -0400
Update of /cvs-repository/Zope3/lib/python/Persistence
In directory cvs.zope.org:/tmp/cvs-serv30575/Persistence
Modified Files:
Cache.py
Log Message:
Code cleanup.
Define invalidateMany() using invalidate() to avoid duplication.
=== Zope3/lib/python/Persistence/Cache.py 1.2 => 1.3 ===
__iter=None
def __init__(self, size=500, inactive=300):
- self.__ghosts={}
- self.__gget=self.__ghosts.get
- self.__active={}
- self.__aget=self.__active.get
- self._size=size
- self._inactive=300
+ self.__ghosts = {}
+ self.__gget = self.__ghosts.get
+ self.__active = {}
+ self.__aget = self.__active.get
+ self._size = size
+ self._inactive = 300
def __getitem__(self, oid):
o = self.__gget(oid, self)
@@ -175,26 +175,19 @@
self.__iter=None
def invalidate(self, oid):
- ob = self.__aget(oid, self)
- if ob is self:
+ ob = self.__aget(oid)
+ if ob is None:
return
ob = ob()
del ob._p_changed
del self.__active[oid]
- ghosts = self.__ghosts
- ghosts[oid] = ref(ob, _dictdel(oid, ghosts))
+ self.__ghosts[oid] = ref(ob, _dictdel(oid, self.__ghosts))
def invalidateMany(self, oids):
if oids is None:
oids = self.__active.keys()
for oid in oids:
- ob = self.__aget(oid, self)
- if ob is self:
- continue
- ob = ob()
- del ob._p_changed
- del self.__active[oid]
- self.__ghosts[oid] = ref(ob, _dictdel(oid, self.__ghosts))
+ self.invalidate(oid)
def statistics(self):
return {