[Checkins] SVN: relstorage/trunk/relstorage/ Put cacheable data in all caches.

Shane Hathaway shane at hathawaymix.org
Sat Oct 17 21:45:22 EDT 2009


Log message for revision 105121:
  Put cacheable data in all caches.
  

Changed:
  U   relstorage/trunk/relstorage/cache.py
  U   relstorage/trunk/relstorage/tests/test_cache.py

-=-
Modified: relstorage/trunk/relstorage/cache.py
===================================================================
--- relstorage/trunk/relstorage/cache.py	2009-10-17 23:54:13 UTC (rev 105120)
+++ relstorage/trunk/relstorage/cache.py	2009-10-18 01:45:21 UTC (rev 105121)
@@ -109,6 +109,8 @@
         self.checkpoints = None
         self.delta_after0 = {}
         self.delta_after1 = {}
+        self.current_tid = 0
+        self.commit_count = object()
 
     def load(self, cursor, oid_int):
         """Load the given object from cache if possible.
@@ -155,8 +157,9 @@
             state, actual_tid_int = self.adapter.mover.load_current(
                 cursor, oid_int)
             assert actual_tid_int == tid_int
+            cache_data = '%s%s' % (p64(tid_int), state or '')
             for client in self.clients_local_first:
-                client.set(cachekey, '%s%s' % (p64(tid_int), state or ''))
+                client.set(cachekey, cache_data)
             return state, tid_int
 
         # Make a list of cache keys to query. The list will have either
@@ -198,7 +201,9 @@
         # cache miss
         state, tid_int = self.adapter.mover.load_current(cursor, oid_int)
         if tid_int:
-            client.set(cp0_key, '%s%s' % (p64(tid_int), state or ''))
+            cache_data = '%s%s' % (p64(tid_int), state or '')
+            for client in self.clients_local_first:
+                client.set(cp0_key, cache_data)
         return state, tid_int
 
 
@@ -357,17 +362,15 @@
 
             if not self.checkpoints:
                 # Initialize the checkpoints.
-                for client in self.clients_global_first:
-                    client.set(
-                        self.checkpoints_key, '%d %d' % new_checkpoints)
+                cache_data = '%d %d' % new_checkpoints
             else:
                 # Suggest reinstatement of the former checkpoints, but
                 # use new checkpoints for this instance. Using new
                 # checkpoints ensures that we don't build up
                 # self.delta_after0 in case the cache is offline.
-                for client in self.clients_global_first:
-                    client.set(
-                        self.checkpoints_key, '%d %d' % self.checkpoints)
+                cache_data = '%d %d' % self.checkpoints
+            for client in self.clients_global_first:
+                client.set(self.checkpoints_key, cache_data)
 
             self.checkpoints = new_checkpoints
             self.delta_after0 = {}

Modified: relstorage/trunk/relstorage/tests/test_cache.py
===================================================================
--- relstorage/trunk/relstorage/tests/test_cache.py	2009-10-17 23:54:13 UTC (rev 105120)
+++ relstorage/trunk/relstorage/tests/test_cache.py	2009-10-18 01:45:21 UTC (rev 105121)
@@ -38,12 +38,12 @@
         self.assertEqual(c.clients_global_first[0].servers, ['host:9999'])
         self.assertEqual(c.prefix, 'myprefix')
 
-    def test_flush_all(self):
+    def test_clear(self):
         from relstorage.tests.fakecache import data
         data.clear()
         c = self._makeOne()
         data['x'] = '1'
-        c.flush_all()
+        c.clear()
         self.assert_(not data)
         self.assertEqual(c.checkpoints, None)
         self.assertEqual(c.delta_after0, {})



More information about the checkins mailing list