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.
12 '''Gets a |Future| with the value of |key| in the object store, or None
13 if |key| is not in the object store.
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.
21 raise NotImplementedError(self.__class__)
23 def Set(self, key, value):
24 '''Sets key -> value in the object store.
26 self.SetMulti({ key: value })
28 def SetMulti(self, items):
29 '''Atomically sets the mapping of keys to values in the object store.
31 raise NotImplementedError(self.__class__)
34 '''Deletes a key from the object store.
38 def DelMulti(self, keys):
39 '''Deletes |keys| from the object store.
41 raise NotImplementedError(self.__class__)