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) |