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

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

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: epic rebase Created 7 years, 5 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
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 future import Future 5 from future import Future
6 6
7 class _SingleGetFuture(object): 7 class _SingleGetFuture(object):
8 def __init__(self, multi_get, key): 8 def __init__(self, multi_get, key):
9 self._future = multi_get 9 self._future = multi_get
10 self._key = key 10 self._key = key
11 11
12 def Get(self): 12 def Get(self):
13 return self._future.Get().get(self._key) 13 return self._future.Get().get(self._key)
14 14
15 class ObjectStore(object): 15 class ObjectStore(object):
16 '''A class for caching picklable objects. 16 '''A class for caching picklable objects.
17 ''' 17 '''
18 def Get(self, key): 18 def Get(self, key):
19 '''Gets a |Future| with the value of |key| in the object store, or None 19 '''Gets a |Future| with the value of |key| in the object store, or None
20 if |key| is not in the object store. 20 if |key| is not in the object store.
21 ''' 21 '''
22 return Future(delegate=_SingleGetFuture(self.GetMulti([key]), key)) 22 return Future(delegate=_SingleGetFuture(self.GetMulti([key]), key))
23 23
24 def GetMulti(self, keys): 24 def GetMulti(self, keys):
25 '''Gets a |Future| with values mapped to |keys| from the object store, with 25 '''Gets a |Future| with values mapped to |keys| from the object store, with
26 any keys not in the object store omitted. 26 any keys not in the object store omitted.
27 ''' 27 '''
28 raise NotImplementedError() 28 raise NotImplementedError(self.__class__)
29 29
30 def Set(self, key, value): 30 def Set(self, key, value):
31 '''Sets key -> value in the object store. 31 '''Sets key -> value in the object store.
32 ''' 32 '''
33 self.SetMulti({ key: value }) 33 self.SetMulti({ key: value })
34 34
35 def SetMulti(self, items): 35 def SetMulti(self, items):
36 '''Atomically sets the mapping of keys to values in the object store. 36 '''Atomically sets the mapping of keys to values in the object store.
37 ''' 37 '''
38 raise NotImplementedError() 38 raise NotImplementedError(self.__class__)
39 39
40 def Del(self, key): 40 def Del(self, key):
41 '''Deletes a key from the object store. 41 '''Deletes a key from the object store.
42 ''' 42 '''
43 self.DelMulti([key]) 43 self.DelMulti([key])
44 44
45 def DelMulti(self, keys): 45 def DelMulti(self, keys):
46 '''Deletes |keys| from the object store. 46 '''Deletes |keys| from the object store.
47 ''' 47 '''
48 raise NotImplementedError() 48 raise NotImplementedError(self.__class__)
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/local_renderer.py ('k') | chrome/common/extensions/docs/server2/object_store_creator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698