MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / expiry_key

Function expiry_key

nodedb/src/engine/kv/engine_helpers.rs:16–21  ·  view source on GitHub ↗

Construct a composite key for the expiry wheel: "{tenant_id}:{collection}\0{key_bytes}". The null byte separator is safe because collection names can't contain null.

(tenant_id: u64, collection: &str, key: &[u8])

Source from the content-addressed store, hash-verified

14/// Construct a composite key for the expiry wheel: "{tenant_id}:{collection}\0{key_bytes}".
15/// The null byte separator is safe because collection names can't contain null.
16pub(super) fn expiry_key(tenant_id: u64, collection: &str, key: &[u8]) -> Vec<u8> {
17 let prefix = format!("{tenant_id}:{collection}\0");
18 let mut composite = prefix.into_bytes();
19 composite.extend_from_slice(key);
20 composite
21}
22
23/// Parse a composite expiry key back into (tenant_id, collection, key_bytes).
24pub(super) fn parse_expiry_key(composite: &[u8]) -> Option<(u64, String, Vec<u8>)> {

Callers 5

atomic_putMethod · 0.85
putMethod · 0.85
deleteMethod · 0.85
expireMethod · 0.85
persistMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected