MCPcopy Create free account
hub / github.com/saltstack/salt / list_items

Method list_items

salt/utils/mmap_cache.py:1514–1560  ·  view source on GitHub ↗

Return all ``(key, value)`` pairs currently in the cache. Reads slot indices from the roster file — O(occupied) regardless of total table size or fill factor. Values stored in set mode are represented as ``True``.

(self)

Source from the content-addressed store, hash-verified

1512 return ret
1513
1514 def list_items(self):
1515 """
1516 Return all ``(key, value)`` pairs currently in the cache.
1517
1518 Reads slot indices from the roster file — O(occupied) regardless of
1519 total table size or fill factor.
1520
1521 Values stored in set mode are represented as ``True``.
1522 """
1523 with self._thread_lock:
1524 if not self.open(write=False):
1525 return []
1526 slots = self._roster_read()
1527 if not slots:
1528 return []
1529
1530 ret = []
1531 for slot in slots:
1532 if slot == 0 or slot >= self.size:
1533 continue
1534 offset = slot * self.slot_size
1535 if self._mm[offset] != OCCUPIED:
1536 continue
1537
1538 key_bytes = self._read_slot_key(offset)
1539 if not key_bytes:
1540 continue
1541
1542 heap_off, length, _ = self._read_slot_pointer(offset)
1543 if length == 0:
1544 value = True
1545 else:
1546 raw = self._read_from_heap(heap_off, length)
1547 if raw is None:
1548 continue
1549 raw = raw.rstrip(b"\x00") or b""
1550 if not raw:
1551 value = True
1552 else:
1553 try:
1554 value = salt.utils.stringutils.to_unicode(raw)
1555 except (UnicodeDecodeError, AttributeError):
1556 value = raw
1557
1558 ret.append((salt.utils.stringutils.to_unicode(key_bytes), value))
1559
1560 return ret
1561
1562 def get_stats(self):
1563 """

Callers 12

list_allFunction · 0.80
list_allFunction · 0.80
compactMethod · 0.80
_rebuild_derivedMethod · 0.80
readerFunction · 0.80
test_list_itemsFunction · 0.80

Calls 6

openMethod · 0.95
_roster_readMethod · 0.95
_read_slot_keyMethod · 0.95
_read_slot_pointerMethod · 0.95
_read_from_heapMethod · 0.95
appendMethod · 0.45