[CalendarServer-changes] [3966] CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 10 09:28:27 PDT 2009


Revision: 3966
          http://trac.macosforge.org/projects/calendarserver/changeset/3966
Author:   wsanchez at apple.com
Date:     2009-04-10 09:28:25 -0700 (Fri, 10 Apr 2009)
Log Message:
-----------
Make memcache set/get no-ops if config.Memcached.ClientEnabled is false

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py

Modified: CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py	2009-04-10 15:09:43 UTC (rev 3965)
+++ CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py	2009-04-10 16:28:25 UTC (rev 3966)
@@ -13,13 +13,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 ##
-from twistedcaldav.directory.directory import DirectoryService, DirectoryRecord, DirectoryError
-from twistedcaldav.config import config
+
 import time
 import types
 import memcache
 import base64
 
+from twistedcaldav.directory.directory import DirectoryService, DirectoryRecord, DirectoryError
+from twistedcaldav.config import config
+
 """
 Caching directory service implementation.
 """
@@ -142,7 +144,6 @@
 
         self._initCaches(cacheClass)
 
-
     def _getMemcacheClient(self, refresh=False):
         if refresh or not hasattr(self, "memcacheClient"):
             self.memcacheClient = memcache.Client(['%s:%s' %
@@ -151,6 +152,9 @@
         return self.memcacheClient
 
     def memcacheSet(self, key, record):
+        if not config.Memcached.ClientEnabled:
+            return
+
         hideService = isinstance(record, DirectoryRecord)
 
         try:
@@ -170,13 +174,15 @@
                 record.service = self
 
     def memcacheGet(self, key):
+        if not config.Memcached.ClientEnabled:
+            return None
+
         key = base64.b64encode(key)
         record = self._getMemcacheClient().get(key)
         if record is not None and isinstance(record, DirectoryRecord):
             record.service = self
         return record
 
-
     def _initCaches(self, cacheClass):
         self._recordCaches = dict([
             (recordType, cacheClass(self, recordType))
@@ -185,7 +191,6 @@
             
         self._disabledKeys = dict([(indexType, dict()) for indexType in self.indexTypes()])
 
-
     def indexTypes(self):
         
         return (
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090410/48ea6618/attachment-0001.html>


More information about the calendarserver-changes mailing list