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

Method tick_expiry

nodedb/src/engine/kv/engine_stats.rs:56–74  ·  view source on GitHub ↗

Advance the expiry wheel and reap expired keys. Call this from the TPC core's event loop at the configured tick interval. Returns a list of `(tenant_id, collection, key)` for each reaped key, enabling the caller to produce WAL tombstones and CDC/keyspace events.

(&mut self, now_ms: u64)

Source from the content-addressed store, hash-verified

54 /// Returns a list of `(tenant_id, collection, key)` for each reaped key,
55 /// enabling the caller to produce WAL tombstones and CDC/keyspace events.
56 pub fn tick_expiry(&mut self, now_ms: u64) -> Vec<ExpiredKey> {
57 let batch = self.expiry.tick(now_ms);
58 let mut reaped = Vec::new();
59
60 for (composite_key, expire_at_ms) in &batch.expired {
61 if let Some((tid, collection, key)) = parse_expiry_key(composite_key)
62 && let Some(table) = self.tables.get_mut(&table_key(tid, &collection))
63 && table.reap_expired(&key, *expire_at_ms)
64 {
65 reaped.push(ExpiredKey {
66 tenant_id: tid,
67 collection,
68 key,
69 });
70 }
71 }
72
73 reaped
74 }
75
76 /// Number of entries tracked in the expiry wheel.
77 pub fn expiry_queue_depth(&self) -> usize {

Callers 2

maybe_run_maintenanceMethod · 0.80
ttl_expiry_via_tickFunction · 0.80

Calls 6

parse_expiry_keyFunction · 0.85
table_keyFunction · 0.85
reap_expiredMethod · 0.80
tickMethod · 0.45
get_mutMethod · 0.45
pushMethod · 0.45

Tested by 1

ttl_expiry_via_tickFunction · 0.64