Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2562)

Unified Diff: chrome/common/extensions/docs/server2/memcache_object_store.py

Issue 10829348: Extensions Docs Server: Large performance increase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes and ObjectStore Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/memcache_object_store.py
diff --git a/chrome/common/extensions/docs/server2/memcache_object_store.py b/chrome/common/extensions/docs/server2/memcache_object_store.py
new file mode 100644
index 0000000000000000000000000000000000000000..96db9e53e8fa89c9b6cf17168e48b066f35a1fdc
--- /dev/null
+++ b/chrome/common/extensions/docs/server2/memcache_object_store.py
@@ -0,0 +1,32 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from appengine_wrappers import memcache
+from object_store import ObjectStore, CACHE_TIMEOUT
+
+class _AsyncMemcacheGetFuture(object):
+ def __init__(self, rpc):
+ self._rpc = rpc
+
+ def Get(self):
+ return self._rpc.get_result()
+
+class MemcacheObjectStore(ObjectStore):
+ def Set(self, key, value, namespace, time=CACHE_TIMEOUT):
+ memcache.set(key, value, namespace=namespace, time=time)
not at google - send to devlin 2012/08/21 00:30:11 yeah, I wonder if we should call set_multi_async h
cduvall 2012/08/21 01:33:33 Done.
+
+ def SetMulti(self, mapping, namespace, time=CACHE_TIMEOUT):
+ client = memcache.Client()
+ client.set_multi_async(mapping, namespace=namespace, time=time)
not at google - send to devlin 2012/08/21 00:30:11 nit: inline client? and below?
cduvall 2012/08/21 01:33:33 Done.
+
+ def Get(self, key, namespace, time=CACHE_TIMEOUT):
+ return memcache.get(key, namespace=namespace)
not at google - send to devlin 2012/08/21 00:30:11 I wonder if this should also return a future (i.e.
cduvall 2012/08/21 01:33:33 Done.
+
+ def GetMulti(self, keys, namespace, time=CACHE_TIMEOUT):
+ client = memcache.Client()
+ rpc = client.get_multi_async(keys, namespace=namespace)
+ return _AsyncMemcacheGetFuture(rpc)
+
+ def Delete(self, key, namespace):
+ memcache.delete(key, namespace=namespace)

Powered by Google App Engine
This is Rietveld 408576698