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 MEMCACHE_FILE_SYSTEM_READ = 'MemcacheFileSystem.Get' | 5 MEMCACHE_FILE_SYSTEM_READ = 'MemcacheFileSystem.Get' |
6 MEMCACHE_FILE_SYSTEM_STAT = 'MemcacheFileSystem.Stat' | 6 MEMCACHE_FILE_SYSTEM_STAT = 'MemcacheFileSystem.Stat' |
| 7 MEMCACHE_URL_FETCHER = 'MemcacheUrlFetcher' |
7 MEMCACHE_BRANCH_UTILITY = 'BranchUtility' | 8 MEMCACHE_BRANCH_UTILITY = 'BranchUtility' |
8 | 9 |
9 class AppEngineMemcache(object): | 10 class AppEngineMemcache(object): |
10 """A wrapper around the standard App Engine memcache that enforces namespace | 11 """A wrapper around the standard App Engine memcache that enforces namespace |
11 use. Uses a branch to make sure there are no key collisions if separate | 12 use. Uses a branch to make sure there are no key collisions if separate |
12 branches cache the same file. | 13 branches cache the same file. |
13 """ | 14 """ |
14 def __init__(self, branch, memcache): | 15 def __init__(self, branch, memcache): |
15 self._branch = branch | 16 self._branch = branch |
16 self._memcache = memcache | 17 self._memcache = memcache |
17 | 18 |
18 def Set(self, key, value, namespace, time=60): | 19 def Set(self, key, value, namespace, time=60): |
19 return self._memcache.set(key, | 20 return self._memcache.set(key, |
20 value, | 21 value, |
21 namespace=self._branch + '.' + namespace, | 22 namespace=self._branch + '.' + namespace, |
22 time=time) | 23 time=time) |
23 | 24 |
24 def Get(self, key, namespace): | 25 def Get(self, key, namespace): |
25 return self._memcache.get(key, namespace=self._branch + '.' + namespace) | 26 return self._memcache.get(key, namespace=self._branch + '.' + namespace) |
26 | 27 |
27 def Delete(self, key, namespace): | 28 def Delete(self, key, namespace): |
28 return self._memcache.delete(key, namespace=self._branch + '.' + namespace) | 29 return self._memcache.delete(key, namespace=self._branch + '.' + namespace) |
OLD | NEW |