MCPcopy
hub / github.com/celery/celery / add

Method add

celery/utils/collections.py:532–542  ·  view source on GitHub ↗

Add a new item, or reset the expiry time of an existing item.

(self, item, now=None)

Source from the content-addressed store, hash-verified

530 self._heap[:] = []
531
532 def add(self, item, now=None):
533 # type: (Any, float) -> None
534 """Add a new item, or reset the expiry time of an existing item."""
535 now = now or time.monotonic()
536 if item in self._data:
537 self.discard(item)
538 entry = (now, item)
539 self._data[item] = entry
540 heappush(self._heap, entry)
541 if self.maxlen and len(self._data) >= self.maxlen:
542 self.purge()
543
544 def update(self, other):
545 # type: (Iterable) -> None

Callers 15

test_addMethod · 0.95
test_purgeMethod · 0.95
test_pickleableMethod · 0.95
test_iterMethod · 0.95
test_reprMethod · 0.95
test_discardMethod · 0.95
test_clearMethod · 0.95
test_updateMethod · 0.95
test_as_dictMethod · 0.95

Calls 2

discardMethod · 0.95
purgeMethod · 0.95

Tested by 15

test_addMethod · 0.76
test_purgeMethod · 0.76
test_pickleableMethod · 0.76
test_iterMethod · 0.76
test_reprMethod · 0.76
test_discardMethod · 0.76
test_clearMethod · 0.76
test_updateMethod · 0.76
test_as_dictMethod · 0.76