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