MCPcopy Index your code
hub / github.com/saltstack/salt / get_mtime

Method get_mtime

salt/utils/mmap_cache.py:1409–1439  ·  view source on GitHub ↗

Return the mtime (Unix timestamp, float seconds) for *key*, or ``None`` if the key does not exist. This reads only the index — no heap access required.

(self, key)

Source from the content-addressed store, hash-verified

1407 return default
1408
1409 def get_mtime(self, key):
1410 """
1411 Return the mtime (Unix timestamp, float seconds) for *key*, or
1412 ``None`` if the key does not exist.
1413
1414 This reads only the index — no heap access required.
1415 """
1416 with self._thread_lock:
1417 if not self.open(write=False):
1418 return None
1419
1420 key_bytes = salt.utils.stringutils.to_bytes(key)[: self.key_size]
1421 h = self._hash(key_bytes)
1422 data_size = self.size - 1
1423
1424 for i in range(data_size):
1425 slot = ((h - 1 + i) % data_size) + 1
1426 offset = slot * self.slot_size
1427 status = self._mm[offset]
1428
1429 if status == EMPTY:
1430 return None
1431 if status == DELETED:
1432 continue
1433 if self._read_slot_key(offset) != key_bytes:
1434 continue
1435
1436 _, _, mtime_ns = self._read_slot_pointer(offset)
1437 return mtime_ns / 1e9
1438
1439 return None
1440
1441 def delete(self, key):
1442 """Mark *key* as DELETED in the index. Heap bytes become unreachable."""

Callers 5

updatedFunction · 0.80
updatedFunction · 0.80
test_get_mtimeFunction · 0.80
test_get_mtime_missingFunction · 0.80

Calls 4

openMethod · 0.95
_hashMethod · 0.95
_read_slot_keyMethod · 0.95
_read_slot_pointerMethod · 0.95

Tested by 3

test_get_mtimeFunction · 0.64
test_get_mtime_missingFunction · 0.64