Commit ef638278 authored by Jens Vagelpohl's avatar Jens Vagelpohl

- LP #143619: Make sure to remove a RAMCache's contents when the

  ZODB object is removed.
parent b13cf2ce
......@@ -181,6 +181,9 @@ Features Added
Bugs Fixed
++++++++++
- LP #143619: Make sure to remove a RAMCache's contents when the
ZODB object is removed.
- LP #143403: Prevent accidental acquisition of objectValues during
recursive ownership changes when the changed object has no
objectValues method.
......
......@@ -172,6 +172,10 @@ class AcceleratedHTTPCacheManager (CacheManager, SimpleItem):
' '
return self.id
security.declarePrivate('_remove_data')
def _remove_data(self):
caches.pop(self.__cacheid)
security.declarePrivate('_resetCacheId')
def _resetCacheId(self):
self.__cacheid = '%s_%f' % (id(self), time.time())
......
......@@ -380,6 +380,10 @@ class RAMCacheManager (CacheManager, SimpleItem):
' '
return self.id
security.declarePrivate('_remove_data')
def _remove_data(self):
caches.pop(self.__cacheid)
security.declarePrivate('_resetCacheId')
def _resetCacheId(self):
self.__cacheid = '%s_%f' % (id(self), time.time())
......
......@@ -5,9 +5,20 @@
OFS.interfaces.IObjectClonedEvent"
handler="Products.StandardCacheManagers.subscribers.cloned" />
<subscriber
for="Products.StandardCacheManagers.RAMCacheManager.RAMCacheManager
zope.lifecycleevent.ObjectRemovedEvent"
handler="Products.StandardCacheManagers.subscribers.removed" />
<subscriber
for="Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager
OFS.interfaces.IObjectClonedEvent"
handler="Products.StandardCacheManagers.subscribers.cloned" />
<subscriber
for="Products.StandardCacheManagers.AcceleratedHTTPCacheManager.AcceleratedHTTPCacheManager
zope.lifecycleevent.ObjectRemovedEvent"
handler="Products.StandardCacheManagers.subscribers.removed" />
</configure>
......@@ -22,3 +22,5 @@ def cloned(obj, event):
"""
obj._resetCacheId()
def removed(obj, event):
obj._remove_data()
......@@ -112,7 +112,11 @@ class CacheManagerLocationTests(CopySupportTestBase):
cache_moved = cachemanager_moved.ZCacheManager_getCache()
self.assertEqual(cache, cache_moved)
# XXX test cache is removed if cachemanager is deleted to prevent leaks?
def test_cache_deleted_on_remove(self):
old_cache = self.cachemanager.ZCacheManager_getCache()
self.folder1.manage_delObjects(['cache'])
new_cache = self.cachemanager.ZCacheManager_getCache()
self.assertNotEqual(old_cache, new_cache)
class AcceleratedHTTPCacheManagerLocationTests(CacheManagerLocationTests):
......
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