Expand description
Redis Streams Integration
Provides high-level Redis Streams functionality for event-driven architectures.
Redis Streams is a data structure that acts like an append-only log, perfect for:
- Event sourcing
- Real-time analytics
- Message queues
- Activity feeds
- Audit logs
§Features
- XADD: Publish events with automatic ID generation
- XREVRANGE: Read latest N entries (newest first)
- XREAD: Read new entries (with optional blocking)
- MAXLEN: Automatic stream trimming to prevent unbounded growth
§Example
use multi_tier_cache::RedisStreams;
let streams = RedisStreams::new("redis://127.0.0.1:6379").await?;
// Publish event
let event_id = streams.stream_add(
"events",
vec![
("user_id".to_string(), "123".to_string()),
("action".to_string(), "login".to_string()),
],
Some(1000) // Keep only latest 1000 events
).await?;
// Read latest 10 events
let latest = streams.stream_read_latest("events", 10).await?;Structs§
- Redis
Streams - Redis Streams client for event-driven architectures
Type Aliases§
- Stream
Entry - Type alias for Redis Stream entry: (ID, Field-Value Pairs)