comparison 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
comparison
equal deleted inserted replaced
3224:0404b306641d 3225:843a9279fb5a
124 self._cache.clear() 124 self._cache.clear()
125 return self.storage.delPrivateNamespace(self.namespace, self.binary, self.profile) 125 return self.storage.delPrivateNamespace(self.namespace, self.binary, self.profile)
126 126
127 def get(self, key, default=None): 127 def get(self, key, default=None):
128 return self._cache.get(key, default) 128 return self._cache.get(key, default)
129
130 def aset(self, key, value):
131 """Async set, return a Deferred fired when value is actually stored"""
132 self._cache.__setitem__(key, value)
133 return self.storage.setPrivateValue(self.namespace, key, value,
134 self.binary, self.profile)
135
136 def adel(self, key):
137 """Async del, return a Deferred fired when value is actually deleted"""
138 self._cache.__delitem__(key)
139 return self.storage.delPrivateValue(
140 self.namespace, key, self.binary, self.profile)
129 141
130 def setdefault(self, key, default): 142 def setdefault(self, key, default):
131 try: 143 try:
132 return self._cache[key] 144 return self._cache[key]
133 except: 145 except: