Adding the orphaned options pages to the navigation
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / object_store.py
blobb56986b349ae0ea1b8bd9eb00d07a27954393f64
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.
5 from future import Future
8 class ObjectStore(object):
9 '''A class for caching picklable objects.
10 '''
11 def Get(self, key):
12 '''Gets a |Future| with the value of |key| in the object store, or None
13 if |key| is not in the object store.
14 '''
15 return self.GetMulti((key,)).Then(lambda keys: keys.get(key))
17 def GetMulti(self, keys):
18 '''Gets a |Future| with values mapped to |keys| from the object store, with
19 any keys not in the object store omitted.
20 '''
21 raise NotImplementedError(self.__class__)
23 def Set(self, key, value):
24 '''Sets key -> value in the object store. Returns a |Future| which is
25 resolved once the key's new value has been stored.
26 '''
27 return self.SetMulti({ key: value })
29 def SetMulti(self, items):
30 '''Atomically sets the mapping of keys to values in the object store.
31 Returns a |Future| which is resolved once the new mapping has been stored.
32 '''
33 raise NotImplementedError(self.__class__)
35 def Del(self, key):
36 '''Deletes a key from the object store.
37 '''
38 self.DelMulti([key])
40 def DelMulti(self, keys):
41 '''Deletes |keys| from the object store.
42 '''
43 raise NotImplementedError(self.__class__)