[CalendarServer-changes] [4004] CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/ memcacheprops.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Apr 13 09:21:50 PDT 2009
Revision: 4004
http://trac.macosforge.org/projects/calendarserver/changeset/4004
Author: wsanchez at apple.com
Date: 2009-04-13 09:21:50 -0700 (Mon, 13 Apr 2009)
Log Message:
-----------
Pull down cache fixes
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/memcacheprops.py
Modified: CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/memcacheprops.py
===================================================================
--- CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/memcacheprops.py 2009-04-13 16:19:28 UTC (rev 4003)
+++ CalendarServer/branches/users/wsanchez/mo-cache/twistedcaldav/memcacheprops.py 2009-04-13 16:21:50 UTC (rev 4004)
@@ -232,6 +232,23 @@
self._propertyCache = self._loadCache()
return self._propertyCache
+ def childCache(self, child):
+ path = child.fp.path
+ key = self._keyForPath(path)
+ propertyCache = self.propertyCache()
+
+ try:
+ childCache, token = propertyCache["key"]
+ except KeyError:
+ self.log_debug("No child property cache for %s" % (child,))
+ childCache, token = ({}, None)
+
+ #message = "No child property cache for %s" % (child,)
+ #log.error(message)
+ #raise AssertionError(message)
+
+ return propertyCache, key, childCache, token
+
def _keyForPath(self, path):
key = "|".join((
self.__class__.__name__,
@@ -263,6 +280,17 @@
result = client.gets_multi((key for key, name in keys))
+ if self.logger.willLogAtLevel("debug"):
+ if abortIfMissing:
+ missing = "missing "
+ else:
+ missing = ""
+ self.log_debug("Loaded keys for %schildren of %s: %s" % (
+ missing,
+ self.collection,
+ [name for key, name in keys],
+ ))
+
missing = tuple((
name for key, name in keys
if key not in result
@@ -317,13 +345,8 @@
return cache
def setProperty(self, child, property):
- path = child.fp.path
- key = self._keyForPath(path)
- propertyCache = self.propertyCache()
- childCache, token = propertyCache.get(key, (None, None))
+ propertyCache, key, childCache, token = self.childCache(child)
- assert childCache is not None, "No child cache?"
-
if childCache.get(property.qname(), None) == property:
# No changes
return
@@ -335,7 +358,8 @@
result = client.set(key, childCache, time=self.cacheTimeout, token=token)
if not result:
delattr(self, "_propertyCache")
- raise MemcacheError("Unable to set property")
+ raise MemcacheError("Unable to set property %s on %s"
+ % (property.sname(), child))
loaded = self._loadCache(childNames=(child.fp.basename(),))
propertyCache.update(loaded.iteritems())
@@ -352,16 +376,11 @@
if client is not None:
result = client.delete(key)
if not result:
- raise MemcacheError("Unable to delete property")
+ raise MemcacheError("Unable to flush cache on %s" % (child,))
def deleteProperty(self, child, qname):
- path = child.fp.path
- key = self._keyForPath(path)
- propertyCache = self.propertyCache()
- childCache, token = propertyCache.get(key, (None, None))
+ propertyCache, key, childCache, token = self.childCache(child)
- assert childCache is not None, "No child cache?"
-
del childCache[qname]
client = self.memcacheClient()
@@ -369,7 +388,8 @@
result = client.set(key, childCache, time=self.cacheTimeout, token=token)
if not result:
delattr(self, "_propertyCache")
- raise MemcacheError("Unable to delete property")
+ raise MemcacheError("Unable to delete property {%s}%s on %s"
+ % (qname[0], qname[1], child))
loaded = self._loadCache(childNames=(child.fp.basename(),))
propertyCache.update(loaded.iteritems())
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090413/259c026c/attachment.html>
More information about the calendarserver-changes
mailing list