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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//! Cache integration for Turso storage
//!
//! This module provides caching layers that integrate with TursoStorage
//! to improve read performance by reducing database queries.
//!
//! ## Architecture
//!
//! ```text
//! Client → CachedTursoStorage → AdaptiveTTLCache → TursoStorage
//! ↓
//! TTL Adaptation Engine
//! Background Cleanup
//! ```
//!
//! ## Components
//!
//! - `config`: Cache configuration types (CacheConfig, CacheStats)
//! - `wrapper`: CachedTursoStorage implementation with transparent caching
//! - `adaptive_ttl`: Generic adaptive TTL cache with access pattern tracking
//! - `ttl_config`: TTL configuration types and validation
//! - `query_cache`: Advanced query result caching with smart invalidation
//! - `invalidation`: Cache invalidation strategies and management
//!
//! ## Usage
//!
//! ```no_run
//! use do_memory_storage_turso::{TursoStorage, CacheConfig};
//!
//! # async fn example() -> anyhow::Result<()> {
//! // Use default cache configuration
//! let storage = TursoStorage::new("file:test.db", "").await?;
//! let cached = storage.with_cache_default();
//!
//! // Or create a custom cache configuration
//! let storage2 = TursoStorage::new("file:test2.db", "").await?;
//! let config = CacheConfig::default();
//! let cached2 = storage2.with_cache(config);
//!
//! // Use cached storage for all operations
//! # Ok(())
//! # }
//! ```
//!
//! ## Advanced Usage (AdaptiveTTLCache)
//!
//! ```no_run
//! use do_memory_storage_turso::cache::{
//! AdaptiveTTLCache, TTLConfig, TTLConfigError
//! };
//! use std::time::Duration;
//!
//! # async fn example() -> Result<(), TTLConfigError> {
//! // Create a custom adaptive TTL cache
//! let config = TTLConfig::new()
//! .with_base_ttl(Duration::from_secs(600))
//! .with_max_entries(5000);
//!
//! let cache = AdaptiveTTLCache::<String, String>::new(config)?;
//!
//! // Use the cache
//! cache.insert("key".to_string(), "value".to_string()).await;
//! let value = cache.get(&"key".to_string()).await;
//!
//! # Ok(())
//! # }
//! ```
//!
//! ## Advanced Query Caching with Smart Invalidation
//!
//! ```no_run
//! use do_memory_storage_turso::cache::{
//! AdvancedQueryCache, AdvancedQueryCacheConfig, InvalidationManager,
//! InvalidationConfig, TableDependency, QueryKey
//! };
//! use std::time::Duration;
//!
//! # async fn example() -> anyhow::Result<()> {
//! // Create advanced query cache
//! let config = AdvancedQueryCacheConfig::default();
//! let (cache, invalidation_rx) = AdvancedQueryCache::new(config);
//!
//! // Create invalidation manager
//! let inv_config = InvalidationConfig::default();
//! let (manager, event_tx) = InvalidationManager::new(inv_config, cache.clone());
//!
//! // Cache a query result
//! let key = QueryKey::from_sql("SELECT * FROM episodes");
//! let data = b"serialized results".to_vec();
//! let deps = vec![TableDependency::Episodes];
//! cache.put(key, data, deps);
//!
//! // Invalidate when episodes table changes
//! // event_tx.send(InvalidationEvent::TableModified { ... })?;
//! # Ok(())
//! # }
//! ```
// Generic adaptive TTL cache implementation
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use CachedTursoStorage;