[CalendarServer-changes] [2507] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Tue May 27 08:34:31 PDT 2008


Revision: 2507
          http://trac.macosforge.org/projects/calendarserver/changeset/2507
Author:   cdaboo at apple.com
Date:     2008-05-27 08:34:31 -0700 (Tue, 27 May 2008)

Log Message:
-----------
When memcached is not being used we can end up with different cache protocols based on the no_invalidation value, so
make the cache protocol an instance property rather than a class property. This also means that each Memcacher will
have its own memcached client. At some point we might want to look into a pooling arrangement for those.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/memcacher.py
    CalendarServer/trunk/twistedcaldav/test/test_memcacher.py

Modified: CalendarServer/trunk/twistedcaldav/memcacher.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/memcacher.py	2008-05-27 15:26:45 UTC (rev 2506)
+++ CalendarServer/trunk/twistedcaldav/memcacher.py	2008-05-27 15:34:31 UTC (rev 2507)
@@ -23,7 +23,6 @@
 import cPickle
 
 class Memcacher(LoggingMixIn):
-    _memcacheProtocol = None
 
     class memoryCacher():
         """
@@ -83,6 +82,9 @@
             nullCacher will be used for the multi-instance case when memcached is not configured.
         @type no_invalidation: C{bool}
         """
+        
+        self._memcacheProtocol = None
+
         self._namespace = namespace
         self._pickle = pickle
         self._noInvalidation = no_invalidation
@@ -94,8 +96,8 @@
         self._reactor = reactor
 
     def _getMemcacheProtocol(self):
-        if Memcacher._memcacheProtocol is not None:
-            return succeed(Memcacher._memcacheProtocol)
+        if self._memcacheProtocol is not None:
+            return succeed(self._memcacheProtocol)
 
         if config.Memcached['ClientEnabled']:
             d = ClientCreator(self._reactor, MemCacheProtocol).connectTCP(
@@ -103,7 +105,7 @@
                 self._port)
     
             def _cacheProtocol(proto):
-                Memcacher._memcacheProtocol = proto
+                self._memcacheProtocol = proto
                 return proto
     
             return d.addCallback(_cacheProtocol)
@@ -111,16 +113,16 @@
         elif config.ProcessType == "Single" or self._noInvalidation:
             
             # NB no need to pickle the memory cacher as it handles python types natively
-            Memcacher._memcacheProtocol = Memcacher.memoryCacher()
+            self._memcacheProtocol = Memcacher.memoryCacher()
             self._pickle = False
-            return succeed(Memcacher._memcacheProtocol)
+            return succeed(self._memcacheProtocol)
 
         else:
             
             # NB no need to pickle the null cacher as it handles python types natively
-            Memcacher._memcacheProtocol = Memcacher.nullCacher()
+            self._memcacheProtocol = Memcacher.nullCacher()
             self._pickle = False
-            return succeed(Memcacher._memcacheProtocol)
+            return succeed(self._memcacheProtocol)
 
     def set(self, key, value):
 

Modified: CalendarServer/trunk/twistedcaldav/test/test_memcacher.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_memcacher.py	2008-05-27 15:26:45 UTC (rev 2506)
+++ CalendarServer/trunk/twistedcaldav/test/test_memcacher.py	2008-05-27 15:34:31 UTC (rev 2507)
@@ -22,7 +22,6 @@
         for processType in ("Single", "Combined",):
             config.processType = processType
 
-            Memcacher._memcacheProtocol = None
             cacher = Memcacher("testing")
     
             result = yield cacher.set("akey", "avalue")
@@ -40,7 +39,6 @@
         for processType in ("Single", "Combined",):
             config.processType = processType
 
-            Memcacher._memcacheProtocol = None
             cacher = Memcacher("testing")
     
             result = yield cacher.get("akey")
@@ -52,7 +50,6 @@
         for processType in ("Single", "Combined",):
             config.processType = processType
 
-            Memcacher._memcacheProtocol = None
             cacher = Memcacher("testing")
     
             result = yield cacher.set("akey", "avalue")
@@ -76,7 +73,6 @@
         for processType in ("Single", "Combined",):
             config.processType = processType
 
-            Memcacher._memcacheProtocol = None
             cacher = Memcacher("testing", pickle=True)
     
             result = yield cacher.set("akey", ["1", "2", "3",])
@@ -100,7 +96,6 @@
         for processType in ("Single", "Combined",):
             config.processType = processType
 
-            Memcacher._memcacheProtocol = None
             cacher = Memcacher("testing", no_invalidation=True)
     
             result = yield cacher.set("akey", ["1", "2", "3",])

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080527/86cb85b8/attachment.htm 


More information about the calendarserver-changes mailing list