Redis
Redis is used for state management, caching, and vector search.
Installation
Docker Setup
Quick Start
Environment Variables
CLI
Use Cases
- Session state caching
- Rate limiting
- Temporary data storage
- Vector search (Redis Stack)
When to Use
✅ Good for:
- Session caching
- Rate limiting
- Real-time features
- Pub/sub messaging
❌ Not recommended for:
- Long-term storage
- Complex queries
- Large datasets
Storage Backend (Advanced)
For training data, sessions, and general persistence, use the RedisBackend:
TrainingStorage is a context manager. Using with (or calling .close() explicitly)
releases the underlying Redis connection at the end of the block — best practice for
long-running processes. On backends without an open resource (e.g. FileBackend)
.close() is a safe no-op.
CLI Usage
RedisBackend Features
Production notes
RedisStateStore.scan_prefix(prefix) iterates the keyspace with a non-blocking SCAN cursor (batches of 500) instead of the O(N) blocking KEYS command. Prefer it over keys(pattern) when listing many keys on a production Redis instance, so a single read never freezes other clients on the single-threaded server.
See Storage Backends for more details.