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 class InMemoryMemcache(object): | |
6 """A memcache that stores items in memory instead of using the memcache | |
7 module. | |
8 """ | |
9 def __init__(self): | |
10 self._cache = {} | |
11 | |
12 def set(self, key, value, namespace, time=60): | |
13 if namespace not in self._cache: | |
14 self._cache[namespace] = {} | |
15 self._cache[namespace][key] = value | |
16 | |
17 def get(self, key, namespace): | |
18 if namespace not in self._cache: | |
19 return None | |
20 return self._cache[namespace].get(key, None) | |
21 | |
22 def delete(self, key, namespace): | |
23 if namespace in self._cache: | |
24 self._cache[namespace].pop(key) | |
OLD | NEW |