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

Method evict_tenant

nodedb/src/engine/sparse/doc_cache.rs:284–295  ·  view source on GitHub ↗

Evict all cache entries belonging to a specific tenant within a database.

(&mut self, database_id: u64, tenant_id: u64)

Source from the content-addressed store, hash-verified

282
283 /// Evict all cache entries belonging to a specific tenant within a database.
284 pub fn evict_tenant(&mut self, database_id: u64, tenant_id: u64) {
285 let shard = match self.shards.get_mut(&database_id) {
286 Some(s) => s,
287 None => return,
288 };
289 let before = shard.entries.len();
290 shard.entries.retain(|k, _| k.tenant_id != tenant_id);
291 shard.order.retain(|k| k.tenant_id != tenant_id);
292 shard.tenant_counts.remove(&tenant_id);
293 let removed = before.saturating_sub(shard.entries.len());
294 self.total = self.total.saturating_sub(removed);
295 }
296
297 /// Cache hit rate (0.0–1.0). Returns 0.0 if no lookups yet.
298 pub fn hit_rate(&self) -> f64 {

Calls 3

get_mutMethod · 0.45
lenMethod · 0.45
removeMethod · 0.45