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)
| 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 | """ |