Caching
Deep dive into Prism's multi-layer caching system and how to optimize it for your workload.
Table of Contents
Cache Architecture
Cache Layers
┌─────────────────────────────────────────────────────────────┐
│ CacheManager │
│ (Orchestrates all caches, tracks chain state) │
└───────────────┬─────────────┬──────────────┬────────────────┘
│ │ │
┌───────▼────┐ ┌────▼────┐ ┌─────▼──────┐
│ BlockCache │ │LogCache │ │TransactionC│
│ │ │ │ │ache │
└────────────┘ └─────────┘ └────────────┘1. Block Cache
2. Log Cache
3. Transaction Cache
Cache Status
Status Values
Status
Meaning
Upstream Calls
Cache Status Flow
Example: Observing Cache Status
Partial Cache Fulfillment
How It Works
Example
Performance Impact
Cache Invalidation
Reorg Detection
Safety Depth
Reorg Handling Flow
Configuration
Monitoring Reorgs
Performance Tuning
Memory vs. Performance
Tuning by Workload
DeFi Applications (Heavy eth_getLogs)
eth_getLogs)Block Explorer (Heavy eth_getBlockByNumber)
eth_getBlockByNumber)Wallet Application (Balanced)
Cache Hit Rate Optimization
Memory Monitoring
Cleanup Interval Tuning
Best Practices
1. Size Caches for Your Working Set
2. Use Appropriate Safety Depth
3. Monitor and Adjust
4. Leverage Partial Caching
5. WebSocket for Real-Time Updates
Troubleshooting
Low Cache Hit Rates
High Memory Usage
Frequent Cache Evictions
Last updated