1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Query caching and prepared statement caching for TideORM
//!
//! This module contains two separate caches:
//! - query-result caching for repeated reads
//! - prepared-statement caching for repeated SQL shapes
//!
//! Start here when a query is correct but slower than expected, or when you
//! need to understand why cached reads are not being reused.
//!
//! Common causes of cache misses are:
//! - a different generated SQL shape than expected
//! - a different explicit cache key
//! - writes invalidating model-scoped cache entries
//! - TTL expiry
//!
//! Practical split:
//! - enable `QueryCache` when repeated reads should return the same payload for a while
//! - use explicit cache keys only when the generated SQL shape is not enough to describe reuse
//! - inspect `PreparedStatementCache` stats when repeated queries are still paying parse or planning cost
//!
//! ## Cache Strategies
//!
//! The query cache can evict entries using different strategies:
//!
//! - **TTL (Time To Live)** - Entries expire after a fixed duration
//! - **LRU (Least Recently Used)** - Oldest entries are evicted when cache is full
//!
//! ## Thread Safety
//!
//! The cache types are shared and synchronized internally, so they can be used
//! from multiple async tasks in the same process.
use OnceLock;
pub use ;
pub use ;
pub use ;
// =============================================================================
// GLOBAL CACHE INSTANCES
// =============================================================================
static GLOBAL_QUERY_CACHE: = new;
static GLOBAL_STMT_CACHE: = new;