Redis Cache Module
The@credo-ts/redis-cache package provides Redis-based caching to improve agent performance by reducing database queries.
Installation
Configuration
Use Cases
DID Resolution Caching
Cache resolved DIDs to avoid repeated resolution:Credential Schema Caching
Cache AnonCreds schemas and credential definitions:Connection State
Cache frequently accessed connection records to reduce database load.Configuration Options
- redis - ioredis client instance (required)
- ttl - Default time-to-live in seconds (default: 3600)
- prefix - Redis key prefix (default: ‘credo’)
Cache Invalidation
The cache automatically invalidates entries when:- TTL expires
- Records are updated
- Agent is shut down
Redis Setup
Development
Production
Consider:- Redis Cluster - For high availability
- Redis Sentinel - For automatic failover
- Persistence - Configure RDB or AOF
- TLS - Enable encrypted connections
- Authentication - Set strong passwords
Performance Benefits
- Reduced database queries for frequently accessed data
- Faster DID resolution (especially for remote DIDs)
- Lower latency for credential operations
- Improved scalability under load
Monitoring
See Also
- Cache Module - Cache API reference
- Storage - Storage architecture
- Agent Configuration - General agent configuration