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
//! # Ferro Cache
//!
//! Caching with tags for the Ferro framework.
//!
//! Provides a unified caching API with support for:
//! - Multiple backends (Redis, in-memory)
//! - Cache tags for bulk invalidation
//! - Remember pattern for lazy caching
//! - TTL (time-to-live) support
//!
//! ## Example
//!
//! ```rust,ignore
//! use ferro_cache::{Cache, CacheConfig};
//! use std::time::Duration;
//!
//! // Create cache
//! let cache = Cache::memory();
//!
//! // Store a value
//! cache.put("user:1", &user, Duration::from_secs(3600)).await?;
//!
//! // Get a value
//! let user: User = cache.get("user:1").await?;
//!
//! // Remember pattern - get from cache or compute
//! let users = cache.remember("users:active", Duration::from_secs(3600), || async {
//! User::where_active().all().await
//! }).await?;
//! ```
//!
//! ## Cache Tags
//!
//! Tags allow bulk invalidation of related cache entries:
//!
//! ```rust,ignore
//! // Store with tags
//! cache.tags(&["users", "admins"])
//! .put("user:1", &admin, Duration::from_secs(3600))
//! .await?;
//!
//! // Flush all entries with a tag
//! cache.tags(&["users"]).flush().await?;
//! ```
pub use ;
pub use Error;
pub use TaggedCache;
pub use MemoryStore;
pub use RedisStore;
/// Re-export for convenience.
pub use async_trait;
pub use serde;