ferro_cache/
lib.rs

1//! # Cancer Cache
2//!
3//! Caching with tags for the Cancer framework.
4//!
5//! Provides a unified caching API with support for:
6//! - Multiple backends (Redis, in-memory)
7//! - Cache tags for bulk invalidation
8//! - Remember pattern for lazy caching
9//! - TTL (time-to-live) support
10//!
11//! ## Example
12//!
13//! ```rust,ignore
14//! use cancer_cache::{Cache, CacheConfig};
15//! use std::time::Duration;
16//!
17//! // Create cache
18//! let cache = Cache::memory();
19//!
20//! // Store a value
21//! cache.put("user:1", &user, Duration::from_secs(3600)).await?;
22//!
23//! // Get a value
24//! let user: User = cache.get("user:1").await?;
25//!
26//! // Remember pattern - get from cache or compute
27//! let users = cache.remember("users:active", Duration::from_secs(3600), || async {
28//!     User::where_active().all().await
29//! }).await?;
30//! ```
31//!
32//! ## Cache Tags
33//!
34//! Tags allow bulk invalidation of related cache entries:
35//!
36//! ```rust,ignore
37//! // Store with tags
38//! cache.tags(&["users", "admins"])
39//!     .put("user:1", &admin, Duration::from_secs(3600))
40//!     .await?;
41//!
42//! // Flush all entries with a tag
43//! cache.tags(&["users"]).flush().await?;
44//! ```
45
46mod cache;
47mod error;
48mod stores;
49mod tagged;
50
51pub use cache::{Cache, CacheConfig, CacheStore};
52pub use error::Error;
53pub use tagged::TaggedCache;
54
55#[cfg(feature = "memory")]
56pub use stores::MemoryStore;
57
58#[cfg(feature = "redis-backend")]
59pub use stores::RedisStore;
60
61/// Re-export for convenience.
62pub use async_trait::async_trait;
63pub use serde;
64
65#[cfg(test)]
66mod tests {
67    #[tokio::test]
68    async fn test_placeholder() {
69        // Placeholder test
70        assert!(true);
71    }
72}