OLD | NEW |
---|---|
(Empty) | |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 from appengine_wrappers import memcache | |
6 from object_store import ObjectStore, CACHE_TIMEOUT | |
7 | |
8 class _AsyncMemcacheGetFuture(object): | |
9 def __init__(self, rpc): | |
10 self._rpc = rpc | |
11 | |
12 def Get(self): | |
13 return self._rpc.get_result() | |
14 | |
15 class MemcacheObjectStore(ObjectStore): | |
16 def Set(self, key, value, namespace, time=CACHE_TIMEOUT): | |
17 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.
| |
18 | |
19 def SetMulti(self, mapping, namespace, time=CACHE_TIMEOUT): | |
20 client = memcache.Client() | |
21 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.
| |
22 | |
23 def Get(self, key, namespace, time=CACHE_TIMEOUT): | |
24 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.
| |
25 | |
26 def GetMulti(self, keys, namespace, time=CACHE_TIMEOUT): | |
27 client = memcache.Client() | |
28 rpc = client.get_multi_async(keys, namespace=namespace) | |
29 return _AsyncMemcacheGetFuture(rpc) | |
30 | |
31 def Delete(self, key, namespace): | |
32 memcache.delete(key, namespace=namespace) | |
OLD | NEW |