Evict the oldest entry from the cache
(&self, statements: &mut HashMap<String, CachedStatement>)
| 214 | |
| 215 | /// Evict the oldest entry from the cache |
| 216 | fn evict_oldest(&self, statements: &mut HashMap<String, CachedStatement>) { |
| 217 | if let Some((oldest_key, _)) = statements |
| 218 | .iter() |
| 219 | .min_by_key(|(_, cached)| cached.last_used) |
| 220 | .map(|(k, v)| (k.clone(), v.last_used)) |
| 221 | { |
| 222 | statements.remove(&oldest_key); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | /// Update the last used time for a cached statement |
| 227 | pub fn touch(&self, query: &str) { |
no test coverage detected