Invalidate all cached entries for a partition (e.g., if it's modified). Sealed partitions are immutable, so this should only be called for active partitions that are still receiving writes.
(&mut self, tenant_id: u64, partition_id: i64)
| 82 | /// Sealed partitions are immutable, so this should only be called for |
| 83 | /// active partitions that are still receiving writes. |
| 84 | pub fn invalidate_partition(&mut self, tenant_id: u64, partition_id: i64) { |
| 85 | let keys: Vec<CacheKey> = self |
| 86 | .entries |
| 87 | .keys() |
| 88 | .filter(|&&(tid, pid, _)| tid == tenant_id && pid == partition_id) |
| 89 | .copied() |
| 90 | .collect(); |
| 91 | |
| 92 | for key in keys { |
| 93 | if let Some(removed) = self.entries.remove(&key) { |
| 94 | self.current_bytes -= removed.len(); |
| 95 | } |
| 96 | } |
| 97 | self.order |
| 98 | .retain(|&(tid, pid, _)| !(tid == tenant_id && pid == partition_id)); |
| 99 | } |
| 100 | |
| 101 | /// Evict all cached entries belonging to a specific tenant. |
| 102 | /// |