[Opensrf-commits] r1151 - trunk/src/python/osrf

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Nov 29 12:01:50 EST 2007


Author: erickson
Date: 2007-11-29 11:43:02 -0500 (Thu, 29 Nov 2007)
New Revision: 1151

Modified:
   trunk/src/python/osrf/cache.py
   trunk/src/python/osrf/net.py
Log:
added cache delete.  updated some logging

Modified: trunk/src/python/osrf/cache.py
===================================================================
--- trunk/src/python/osrf/cache.py	2007-11-29 16:42:04 UTC (rev 1150)
+++ trunk/src/python/osrf/cache.py	2007-11-29 16:43:02 UTC (rev 1151)
@@ -1,5 +1,6 @@
 import memcache
 from osrf.json import osrfObjectToJSON, osrfJSONToObject
+from osrf.log import *
 
 '''
 Abstracted OpenSRF caching interface.
@@ -23,7 +24,7 @@
             '''
         global _client
         if servers:
-            self.client = memcache.Client(server, debug=0)
+            self.client = memcache.Client(server, debug=1)
         else:
             if not _client:
                 raise CacheException("not connected to any memcache servers.  try CacheClient.connect(servers)")
@@ -33,14 +34,23 @@
         global defaultTimeout
         if timeout is None:
             timeout = defaultTimeout
-        self.client.set(key, osrfObjectToJSON(val), timeout)
+        s = osrfObjectToJSON(val)
+        osrfLogInternal("cache: %s => %s" % (str(key), s))
+        return self.client.set(str(key), s, timeout)
 
     def get(self, key):
-        return osrfJSONToObject(self.client.get(key) or "null")
+        o = self.client.get(str(key))
+        osrfLogInternal("cache: fetching %s => %s" % (str(key), o))
+        return osrfJSONToObject(o or "null")
 
+    def delete(self, key):
+        osrfLogInternal("cache: deleting %s" % str(key))
+        self.client.delete(str(key))
+
     @staticmethod
     def connect(svrs):
         global _client
-        _client = memcache.Client(svrs, debug=0)
+        osrfLogDebug("cache: connecting to servers %s" % str(svrs))
+        _client = memcache.Client(svrs, debug=1)
 
 

Modified: trunk/src/python/osrf/net.py
===================================================================
--- trunk/src/python/osrf/net.py	2007-11-29 16:42:04 UTC (rev 1150)
+++ trunk/src/python/osrf/net.py	2007-11-29 16:43:02 UTC (rev 1151)
@@ -131,12 +131,10 @@
         if len(self.queue) == 0:
             while timeout >= 0 and len(self.queue) == 0:
                 starttime = time.time()
-                osrfLogInternal("going into stream loop at " + str(starttime))
                 act = self.get_stream().loop_iter(timeout)
                 endtime = time.time() - starttime
                 timeout -= endtime
-                osrfLogInternal("exiting stream loop after %s seconds" % str(endtime))
-                osrfLogInternal("act = %s : queue length = %d" % (act, len(self.queue)) )
+                osrfLogInternal("exiting stream loop after %s seconds. act=%s, queue size=%d" % (str(endtime),act, len(self.queue)))
                 if not act: self.idle()
 
         # if we've acquired a message, handle it



More information about the opensrf-commits mailing list