Multi-Backend State Persistence
Support for multiple storage backends including Redis, SQLite, and PostgreSQL.
Overview
Multi-backend support allows choosing the right storage backend for your use case.
Supported Backends
See State Persistence and Redis Backend for detailed configuration.
Redis (Recommended for Production)
- High performance
- Distributed support
- TTL and expiration
SQLite (Development)
- File-based storage
- No external dependencies
- Good for testing
PostgreSQL (Enterprise)
- ACID compliance
- Advanced querying
- Scalable
Configuration
from recoagent.state import RedisStatePersistence
# Redis backend
redis_persistence = RedisStatePersistence(
redis_url="redis://localhost:6379/0",
compression_type=CompressionType.LZ4
)
Choosing a Backend
| Backend | Use Case | Performance | Scalability |
|---|---|---|---|
| Redis | Production | Excellent | High |
| SQLite | Development | Good | Low |
| PostgreSQL | Enterprise | Good | Very High |
Best Practices
- Redis for Production: Use Redis for production workloads
- SQLite for Testing: Use SQLite for development and testing
- PostgreSQL for Enterprise: Use PostgreSQL for complex queries