added a default timeout cache setting
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 27 Nov 2007 22:39:45 +0000 (22:39 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 27 Nov 2007 22:39:45 +0000 (22:39 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1149 9efc2488-bf62-4759-914b-345cdb29e865

src/python/osrf/cache.py

index 2a8d30a..b34309d 100644 (file)
@@ -7,6 +7,7 @@ Requires memcache: ftp://ftp.tummy.com/pub/python-memcached/
 '''
 
 _client = None
+defaultTimeout = 0
 
 class CacheException(Exception):
     def __init__(self, info):
@@ -28,7 +29,10 @@ class CacheClient(object):
                 raise CacheException("not connected to any memcache servers.  try CacheClient.connect(servers)")
             self.client = _client
 
-    def put(self, key, val, timeout=0):
+    def put(self, key, val, timeout=None):
+        global defaultTimeout
+        if timeout is None:
+            timeout = defaultTimeout
         self.client.set(key, osrfObjectToJSON(val), timeout)
 
     def get(self, key):