MCPcopy Create free account
hub / github.com/coleifer/huey / put_if_empty

Method put_if_empty

huey/storage.py:222–233  ·  view source on GitHub ↗

Atomically write data only if the key is not already set. :param bytes key: Key to check/set. :param bytes value: Arbitrary data. :return: Boolean whether key/value was set.

(self, key, value)

Source from the content-addressed store, hash-verified

220 raise NotImplementedError
221
222 def put_if_empty(self, key, value):
223 """
224 Atomically write data only if the key is not already set.
225
226 :param bytes key: Key to check/set.
227 :param bytes value: Arbitrary data.
228 :return: Boolean whether key/value was set.
229 """
230 if self.has_data_for_key(key):
231 return False
232 self.put_data(key, value)
233 return True
234
235 def incr(self, key, amount=1):
236 """

Callers

nothing calls this directly

Calls 2

has_data_for_keyMethod · 0.95
put_dataMethod · 0.95

Tested by

no test coverage detected