[CalendarServer-changes] [3984] CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Sat Apr 11 16:14:56 PDT 2009


Revision: 3984
          http://trac.macosforge.org/projects/calendarserver/changeset/3984
Author:   wsanchez at apple.com
Date:     2009-04-11 16:14:55 -0700 (Sat, 11 Apr 2009)
Log Message:
-----------
Trap DELETE and flush caches

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/memcacheprops.py
    CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/static.py

Modified: CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/memcacheprops.py
===================================================================
--- CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/memcacheprops.py	2009-04-11 21:21:33 UTC (rev 3983)
+++ CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/memcacheprops.py	2009-04-11 23:14:55 UTC (rev 3984)
@@ -340,6 +340,20 @@
             loaded = self._loadCache(childNames=(child.fp.basename(),))
             propertyCache.update(loaded.iteritems())
 
+    def flushCache(self, child):
+        path = child.fp.path
+        key = self._keyForPath(path)
+        propertyCache = self.propertyCache()
+
+        if key in propertyCache:
+            del propertyCache[key]
+
+        client = self.memcacheClient()
+        if client is not None:
+            result = client.delete(key)
+            if not result:
+                raise MemcacheError("Unable to delete property")
+
     def deleteProperty(self, child, qname):
         path = child.fp.path
         key = self._keyForPath(path)
@@ -375,6 +389,9 @@
             parentPropertyCache = self.parentPropertyCollection.propertyCache()
             return parentPropertyCache.get(key, ({}, None))[0]
 
+        def flushCache(self):
+            self.parentPropertyCollection.flushCache(self.child)
+
         def get(self, qname, cache=True):
             if cache:
                 propertyCache = self.propertyCache()

Modified: CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/static.py	2009-04-11 21:21:33 UTC (rev 3983)
+++ CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/static.py	2009-04-11 23:14:55 UTC (rev 3984)
@@ -393,6 +393,9 @@
         similar = super(CalDAVFile, self).createSimilarFile(path)
 
         if isCalendarCollectionResource(self):
+            #
+            # Override the dead property store
+            #
             superDeadProperties = similar.deadProperties
 
             def deadProperties():
@@ -405,6 +408,20 @@
 
             similar.deadProperties = deadProperties
 
+            #
+            # Override DELETE
+            #
+            superDelete = similar.http_DELETE
+
+            def http_DELETE(request):
+                # Wipe the cache
+                similar.deadProperties().flushCache()
+
+                # Call original delete method
+                return superDelete(request)
+
+            similar.http_DELETE = http_DELETE
+
         return similar
 
     def updateCTag(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090411/af361daa/attachment.html>


More information about the calendarserver-changes mailing list