[CalendarServer-changes] [3374] CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Nov 12 16:10:41 PST 2008
Revision: 3374
http://trac.macosforge.org/projects/calendarserver/changeset/3374
Author: wsanchez at apple.com
Date: 2008-11-12 16:10:41 -0800 (Wed, 12 Nov 2008)
Log Message:
-----------
Add negative record lookup cache. Ride on the existing disabled records cache.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
Modified: CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py 2008-11-12 19:34:40 UTC (rev 3373)
+++ CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py 2008-11-13 00:10:41 UTC (rev 3374)
@@ -271,10 +271,18 @@
try:
return self.recordsForType(recordType)[shortName]
except KeyError:
+ # Check negative cache
+ if shortName in self._storage(recordType)["disabled names"]:
+ return None
+
# Cache miss; try looking the record up, in case it is new
# FIXME: This is a blocking call (hopefully it's a fast one)
self.reloadCache(recordType, shortName=shortName)
- return self.recordsForType(recordType).get(shortName, None)
+ record = self.recordsForType(recordType).get(shortName, None)
+ if record is None:
+ # Add to negative cache
+ self._storage(recordType)["disabled names"].add(shortName)
+ return record
def recordWithGUID(self, guid):
def lookup():
@@ -288,6 +296,10 @@
record = lookup()
if record is None:
+ # Check negative cache
+ if guid in self._storage(recordType)["disabled guids"]:
+ return None
+
# Cache miss; try looking the record up, in case it is new
for recordType in self.recordTypes():
self.reloadCache(recordType, guid=guid)
@@ -297,6 +309,8 @@
% (guid, recordType))
break
else:
+ # Add to negative cache
+ self._storage(recordType)["disabled guids"].add(guid)
self.log_info("Unable to find any record with GUID %s" % (guid,))
return record
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081112/55c37681/attachment.html>
More information about the calendarserver-changes
mailing list