Expand description
Redis storage backend implementation
This module provides a production-ready Redis storage backend with comprehensive features including connection pooling, TTL support, atomic operations, pub/sub, distributed locking, and cache statistics.
§Features
- Connection pooling with deadpool-redis
- TTL (time-to-live) support for all entries
- Atomic operations (INCR, DECR, CAS)
- Key prefix namespacing
- Pub/Sub support for real-time messaging
- Pipeline operations for batching
- Lua scripting for complex atomic operations
- Cache statistics (hits, misses, evictions)
- Full CRUD operations with JSON serialization
- Distributed locking support
§Architecture
The Redis backend uses a key structure with namespacing:
{prefix}:{table}:{key}-> JSON value{prefix}:{table}:{key}:version-> version number{prefix}:{table}:{key}:metadata-> metadata JSON{prefix}:stats-> cache statistics
§Example
use processor::storage::redis::RedisStorage;
use processor::storage::config::RedisConfig;
use processor::storage::traits::Storage;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = RedisConfig::default();
let mut storage = RedisStorage::new(config).await?;
storage.initialize().await?;
// Use storage operations
storage.insert("users", "user:1", &user).await?;
Ok(())
}Structs§
- Redis
Storage - Redis storage backend with connection pooling and advanced features