Evict all cached entries belonging to a specific tenant. Used during tenant purge to ensure zero residual cached data.
(&mut self, tenant_id: u64)
| 102 | /// |
| 103 | /// Used during tenant purge to ensure zero residual cached data. |
| 104 | pub fn evict_tenant(&mut self, tenant_id: u64) { |
| 105 | let keys: Vec<CacheKey> = self |
| 106 | .entries |
| 107 | .keys() |
| 108 | .filter(|&&(tid, _, _)| tid == tenant_id) |
| 109 | .copied() |
| 110 | .collect(); |
| 111 | |
| 112 | for key in keys { |
| 113 | if let Some(removed) = self.entries.remove(&key) { |
| 114 | self.current_bytes -= removed.len(); |
| 115 | } |
| 116 | } |
| 117 | self.order.retain(|&(tid, _, _)| tid != tenant_id); |
| 118 | } |
| 119 | |
| 120 | /// Number of cached entries. |
| 121 | pub fn len(&self) -> usize { |