OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 class InMemoryMemcache(object): | 5 class InMemoryMemcache(object): |
6 """A memcache that stores items in memory instead of using the memcache | 6 """A memcache that stores items in memory instead of using the memcache |
7 module. | 7 module. |
8 """ | 8 """ |
9 def __init__(self): | 9 def __init__(self): |
10 self._cache = {} | 10 self._cache = {} |
11 | 11 |
12 def Set(self, key, value, namespace, time=60): | 12 def set(self, key, value, namespace, time=60): |
not at google - send to devlin
2012/07/31 06:04:36
this has different interface to AppEngineMemcache
| |
13 if namespace not in self._cache: | 13 if namespace not in self._cache: |
14 self._cache[namespace] = {} | 14 self._cache[namespace] = {} |
15 self._cache[namespace][key] = value | 15 self._cache[namespace][key] = value |
16 | 16 |
17 def Get(self, key, namespace): | 17 def get(self, key, namespace): |
18 if namespace not in self._cache: | 18 if namespace not in self._cache: |
19 return None | 19 return None |
20 return self._cache[namespace].get(key, None) | 20 return self._cache[namespace].get(key, None) |
21 | 21 |
22 def Delete(self, key, namespace): | 22 def delete(self, key, namespace): |
23 if namespace in self._cache: | 23 if namespace in self._cache: |
24 self._cache[namespace].pop(key) | 24 self._cache[namespace].pop(key) |
OLD | NEW |