Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/common/extensions/docs/server2/object_store.py

Issue 10829348: Extensions Docs Server: Large performance increase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 future import Future
6
7 # Default to a 5 minute cache timeout.
8 CACHE_TIMEOUT = 300
9
10 BRANCH_UTILITY = 'BranchUtility'
11 FILE_SYSTEM_CACHE = 'FileSystemCache'
12 FILE_SYSTEM_CACHE_LISTING = 'FileSystemCacheListing'
13 FILE_SYSTEM_READ = 'Read'
14 FILE_SYSTEM_STAT = 'Stat'
15 GITHUB_STAT = 'GithubStat'
16
17 class _SingleGetFuture(object):
18 def __init__(self, multi_get, key):
19 self._future = multi_get
20 self._key = key
21
22 def Get(self):
23 return self._future.Get()[self._key]
24
25 class ObjectStore(object):
26 """A class for caching picklable objects.
27 """
28 def Set(self, key, value, namespace, time=CACHE_TIMEOUT):
29 """Sets key -> value in the object store, with the specified timeout.
30 """
31 self.SetMulti({ key: value }, namespace, time=time)
32
33 def SetMulti(self, mapping, namespace, time=CACHE_TIMEOUT):
34 """Sets the mapping of keys to values in the object store with the specified
35 timeout.
36 """
37 raise NotImplementedError()
38
39 def Get(self, key, namespace, time=CACHE_TIMEOUT):
40 """Gets a |Future| with the value of |key| in the object store, or None
41 if |key| is not in the object store.
42 """
43 return Future(delegate=_SingleGetFuture(
44 self.GetMulti([key], namespace, time=time),
45 key))
46
47 def GetMulti(self, keys, namespace, time=CACHE_TIMEOUT):
48 """Gets a |Future| with values mapped to |keys| from the object store, with
49 any keys not in the object store mapped to None.
50 """
51 raise NotImplementedError()
52
53 def Delete(self, key, namespace):
54 """Deletes a key from the object store.
55 """
56 raise NotImplementedError()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698