Mercurial > libervia-backend
diff sat/memory/persistent.py @ 3225:843a9279fb5a
core (memory/persistent): implemented `aset` and `adel`:
those methods are async variants of __setitem__ and __delitem__, they return a Deferred
fired when the value is actually set/removed from storage.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 22 Mar 2020 18:35:22 +0100 |
parents | 559a625a236b |
children | 78fea49735c5 |
line wrap: on
line diff
--- a/sat/memory/persistent.py Sun Mar 22 14:31:48 2020 +0100 +++ b/sat/memory/persistent.py Sun Mar 22 18:35:22 2020 +0100 @@ -127,6 +127,18 @@ def get(self, key, default=None): return self._cache.get(key, default) + def aset(self, key, value): + """Async set, return a Deferred fired when value is actually stored""" + self._cache.__setitem__(key, value) + return self.storage.setPrivateValue(self.namespace, key, value, + self.binary, self.profile) + + def adel(self, key): + """Async del, return a Deferred fired when value is actually deleted""" + self._cache.__delitem__(key) + return self.storage.delPrivateValue( + self.namespace, key, self.binary, self.profile) + def setdefault(self, key, default): try: return self._cache[key]