MCPcopy Create free account
hub / github.com/erans/pgsqlite / maintenance

Method maintenance

src/optimization/mod.rs:172–204  ·  view source on GitHub ↗

Perform periodic maintenance (cleanup caches, etc.)

(&self)

Source from the content-addressed store, hash-verified

170
171 /// Perform periodic maintenance (cleanup caches, etc.)
172 pub fn maintenance(&self) {
173 if !self.enabled {
174 return;
175 }
176
177 info!("Performing optimization manager maintenance");
178
179 // Cleanup context cache
180 {
181 let mut context_optimizer = self.context_optimizer.write().unwrap();
182 context_optimizer.cleanup_cache();
183 }
184
185 // Cleanup schema cache
186 self.lazy_schema_loader.cleanup_cache();
187
188 // Clear pattern cache if it gets too large
189 {
190 let mut pattern_optimizer = self.pattern_optimizer.write().unwrap();
191 let cache_hit_rate = pattern_optimizer.get_cache_hit_rate();
192 if cache_hit_rate < 0.5 {
193 pattern_optimizer.clear_cache();
194 info!("Cleared pattern cache due to low hit rate: {:.2}", cache_hit_rate);
195 }
196 }
197
198 // Clear read-only cache if hit rate is low
199 let read_only_hit_rate = self.read_only_optimizer.get_cache_hit_rate();
200 if read_only_hit_rate < 0.3 {
201 self.read_only_optimizer.clear_cache();
202 info!("Cleared read-only cache due to low hit rate: {:.2}", read_only_hit_rate);
203 }
204 }
205
206 /// Get overall optimization effectiveness
207 pub fn get_effectiveness_metrics(&self) -> OptimizationEffectiveness {

Callers

nothing calls this directly

Calls 3

cleanup_cacheMethod · 0.45
get_cache_hit_rateMethod · 0.45
clear_cacheMethod · 0.45

Tested by

no test coverage detected