Insert a plan. On capacity overflow, the oldest entry is evicted.
(&self, key: PlanCacheKey, plan: std::sync::Arc<PhysicalPlan>)
| 156 | |
| 157 | /// Insert a plan. On capacity overflow, the oldest entry is evicted. |
| 158 | pub fn insert(&self, key: PlanCacheKey, plan: std::sync::Arc<PhysicalPlan>) { |
| 159 | let mut inner = self.inner.lock().unwrap_or_else(|p| p.into_inner()); |
| 160 | // Remove any existing entry with the same key first. |
| 161 | inner.entries.retain(|e| e.key != key); |
| 162 | if inner.entries.len() >= inner.capacity { |
| 163 | inner.entries.pop_front(); |
| 164 | } |
| 165 | inner.entries.push_back(CacheEntry { key, plan }); |
| 166 | } |
| 167 | |
| 168 | /// Evict all plan entries whose `version_set` references `name` at any |
| 169 | /// version other than `new_version`. Also removes the corresponding |