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