[CalendarServer-changes] [3389] CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/ directory/appleopendirectory.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Nov 17 15:03:07 PST 2008
Revision: 3389
http://trac.macosforge.org/projects/calendarserver/changeset/3389
Author: wsanchez at apple.com
Date: 2008-11-17 15:03:07 -0800 (Mon, 17 Nov 2008)
Log Message:
-----------
Add negative cache
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/appleopendirectory.py
Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/appleopendirectory.py 2008-11-17 22:53:18 UTC (rev 3388)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/appleopendirectory.py 2008-11-17 23:03:07 UTC (rev 3389)
@@ -430,10 +430,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():
@@ -449,6 +457,10 @@
if record is None:
# Cache miss; try looking the record up, in case it is new
for recordType in self.recordTypes():
+ # Check negative cache
+ if guid in self._storage(recordType)["disabled guids"]:
+ break
+
self.reloadCache(recordType, guid=guid)
record = lookup()
if record is not None:
@@ -456,6 +468,8 @@
% (guid, recordType))
break
else:
+ # Nothing found; 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/20081117/1192a300/attachment.html>
More information about the calendarserver-changes
mailing list