Quick Start
How It Works
Redis stores different types of state data optimized for performance:| Data Type | Use Case | Performance |
|---|---|---|
| Strings | Simple key-value state | O(1) get/set |
| Hashes | Agent metadata, user preferences | O(1) field access |
| Sets | Active sessions, user lists | O(1) membership tests |
| Sorted Sets | Leaderboards, time-based data | O(log N) range queries |
| JSON | Complex state objects | Native JSON operations |
Configuration Options
Redis URL Formats
Advanced Redis Configuration
Docker Setup
Quick Redis setup with Docker:State Management Patterns
Key-Value State
JSON State Objects
Hash-Based State
Real-Time Features
Session Tracking
Pub/Sub for Real-Time Updates
Best Practices
Memory Management
Memory Management
- Set appropriate maxmemory limit for your Redis instance
- Use LRU or LFU eviction policies for automatic cleanup
- Monitor memory usage and plan for peak loads
- Use key expiration (TTL) for temporary data
Data Organization
Data Organization
- Use consistent key naming patterns (prefix:type:identifier)
- Group related data using key prefixes or Redis databases
- Consider data access patterns when choosing Redis data types
- Use Redis modules (JSON, Search) for complex operations
Persistence and Backup
Persistence and Backup
- Enable Redis persistence (RDB snapshots + AOF logs)
- Regular backup of RDB files for disaster recovery
- Test backup restoration procedures
- Monitor Redis logs for persistence issues
High Availability
High Availability
- Set up Redis Sentinel for automatic failover
- Use Redis Cluster for horizontal scaling
- Monitor Redis health and performance metrics
- Plan for network partitions and split-brain scenarios
Related
MongoDB State Store
Alternative NoSQL state storage with document features
Database Persistence Overview
Compare all available persistence backends

