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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//! Cache management for Armature framework.
//!
//! Provides a unified interface for working with various cache backends
//! including Redis and Memcached, with advanced features like tag-based
//! invalidation and multi-tier caching.
//!
//! # Features
//!
//! - `redis` - Enable Redis cache support (enabled by default)
//! - `memcached` - Enable Memcached cache support (requires explicit opt-in)
//! - **Tag-based invalidation** - Invalidate multiple cache entries by tag
//! - **Multi-tier caching** - L1 (in-memory) + L2 (distributed) layers
//! - **Cache decorators** - `#[cache]` attribute for automatic caching
//!
//! # Examples
//!
//! ## Redis Cache
//!
//! ```no_run
//! use armature_cache::*;
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), CacheError> {
//! let redis_config = CacheConfig::redis("redis://localhost:6379")?;
//! let redis_cache = RedisCache::new(redis_config).await?;
//!
//! redis_cache.set_json("key", "value".to_string(), Some(Duration::from_secs(60))).await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Tag-based Invalidation
//!
//! ```no_run
//! use armature_cache::*;
//! use std::sync::Arc;
//!
//! # async fn example() -> Result<(), CacheError> {
//! # let redis_cache = Arc::new(InMemoryCache::new());
//! let tagged = TaggedCache::new(redis_cache);
//!
//! // Set with tags
//! tagged.set_with_tags(
//! "user:123",
//! r#"{"name":"Alice"}"#.to_string(),
//! &["users", "active-users"],
//! None,
//! ).await?;
//!
//! // Invalidate all entries with "users" tag
//! tagged.invalidate_tag("users").await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Multi-tier Caching
//!
//! ```no_run
//! use armature_cache::*;
//! use std::sync::Arc;
//!
//! # async fn example() -> Result<(), CacheError> {
//! # let redis_cache = Arc::new(InMemoryCache::new());
//! let l1 = Arc::new(InMemoryCache::new());
//! let l2 = redis_cache;
//!
//! let tiered = TieredCache::new(l1, l2);
//!
//! // Automatically uses L1 (fast) and falls back to L2
//! tiered.set("key", "value".to_string(), None).await?;
//! let value = tiered.get("key").await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Memcached Cache (requires `memcached` feature)
//!
//! ```ignore
//! use armature_cache::*;
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), CacheError> {
//! let memcached_config = CacheConfig::memcached("memcache://localhost:11211")?;
//! let memcached_cache = MemcachedCache::new(memcached_config).await?;
//!
//! memcached_cache.set_json("key", "value".to_string(), Some(Duration::from_secs(60))).await?;
//!
//! Ok(())
//! }
//! ```
pub use CacheConfig;
pub use ;
pub use *;
pub use TaggedCache;
pub use CacheManager;
pub use ;
pub use CacheStore;
pub use RedisCache;
pub use MemcachedCache;
/// Re-export commonly used types