[Checkins] SVN: relstorage/trunk/relstorage/storage.py Reduce memcache traffic by not replacing state when it is already stored

Shane Hathaway shane at hathawaymix.org
Wed Oct 7 18:03:06 EDT 2009


Log message for revision 104898:
  Reduce memcache traffic by not replacing state when it is already stored

Changed:
  U   relstorage/trunk/relstorage/storage.py

-=-
Modified: relstorage/trunk/relstorage/storage.py
===================================================================
--- relstorage/trunk/relstorage/storage.py	2009-10-07 20:55:27 UTC (rev 104897)
+++ relstorage/trunk/relstorage/storage.py	2009-10-07 22:03:06 UTC (rev 104898)
@@ -392,14 +392,15 @@
                     state = str(state or '')
                     if tid_int is not None:
                         # cache the result
+                        to_cache = {}
                         tid = p64(tid_int)
+                        new_cache_data = tid + state
+                        if new_cache_data != cache_data:
+                            to_cache[state_key] = new_cache_data
                         if my_tid and my_tid != tid_int:
-                            cache.set_multi({
-                                state_key: tid + state,
-                                backptr_key: tid,
-                                })
-                        else:
-                            cache.set(state_key, tid + state)
+                            to_cache[backptr_key] = tid
+                        if to_cache:
+                            cache.set_multi(to_cache)
         finally:
             self._lock_release()
 



More information about the checkins mailing list