Expand description
Query Cache for parsed SQL statements
This module provides a cache for previously parsed SQL queries, storing the parse tree to avoid the overhead of parsing the same query multiple times.
§Example
ⓘ
let cache = QueryCache::<()>::new(1000);
// First query - will be parsed and cached
if let Some(plan) = cache.get("SELECT * FROM users") {
// Use cached plan
} else {
// Parse and cache
let stmt = parse(sql);
cache.put(sql, stmt, false, 0);
}
// Second identical query - retrieved from cache
let plan = cache.get("SELECT * FROM users").unwrap();Re-exports§
pub use crate::compiled_plan::CompiledCountDistinct;pub use crate::compiled_plan::CompiledCountStar;pub use crate::compiled_plan::CompiledExecution;pub use crate::compiled_plan::CompiledInsert;pub use crate::compiled_plan::CompiledPkDelete;pub use crate::compiled_plan::CompiledPkLookup;pub use crate::compiled_plan::CompiledPkUpdate;pub use crate::compiled_plan::CompiledUpdateColumn;pub use crate::compiled_plan::PkValueSource;pub use crate::compiled_plan::UpdateValueSource;
Structs§
- Cache
Stats - Cache statistics
- Cached
Plan Ref - Lightweight reference to a cached plan for query execution. Contains only what’s needed to execute: the immutable statement and param info.
- Cached
Query Plan - Represents a parsed and prepared statement stored in the cache
- Parameter
Contract - Exact parameter shape owned by one parsed statement.
- Query
Cache - Query cache for parsed SQL statements
Constants§
- DEFAULT_
CACHE_ SIZE - Default cache size (number of cached plans)