Overview
The cache stores:- Transaction envelopes fetched from RPC
- Ledger footprint data (read/write sets)
- Simulation results and traces
- Contract WASM bytecode
- Source maps and debug symbols
- Faster repeated debugging of the same transaction
- Offline analysis after initial data fetch
- Reduced RPC load and bandwidth usage
- Consistent results across debugging sessions
Cache location
Default cache directory:The cache directory is created automatically on first use.
Cache commands
Check cache status
View cache size and usage statistics:Clean old entries
Remove old cached files using LRU (Least Recently Used) strategy:
Skip confirmation:
Clear all cache
Delete all cached files:RPC cache management
Erst also maintains a separate SQLite database for RPC fetch results:- Transaction envelopes
- Ledger entries
- Contract code
- Network metadata
Clean RPC cache by age
Remove entries older than N days:Clean RPC cache by network
Remove entries for a specific network:- Testnet resets
- Switching development focus
- Freeing space from old test data
Combine filters
Remove testnet entries older than 30 days:Clear all RPC cache
Remove all RPC cache entries:At least one filter must be specified when cleaning RPC cache:
--older-than, --network, or --all.Cache configuration
Maximum size
Default maximum cache size: 1 GB Configure via code ininternal/cache/cache.go:
LRU strategy
When cleaning, Erst:- Lists all cached files with access times
- Sorts by least recently used
- Deletes files until size drops to 50% of maximum
- Preserves recently accessed files
File organization
Cache files are organized by type:Cache behavior
When cache is used
Erst uses cached data when:- Debugging the same transaction multiple times
- Working offline (no network access)
- RPC endpoints are slow or rate-limited
- Session is resumed from saved state
When cache is bypassed
Erst fetches fresh data when:- Cache entry doesn’t exist
- Cache entry is corrupted
- Explicit cache bypass flag is used
- Network status has changed
Cache invalidation
Cache entries never expire automatically during use. They’re only removed:- During manual cleaning (
erst cache clean) - When maximum size is exceeded
- When manually cleared (
erst cache clear) - When LRU cleanup runs
Transaction data on Stellar is immutable, so cached transactions remain valid indefinitely.
Optimization strategies
Regular maintenance
Schedule periodic cache cleaning:Network-specific cleanup
After testnet resets:Disk space management
If running low on disk space:# Remove entries older than 7 days
erst cache clean --older-than 7 --force
# Or clear everything
erst cache clear --force
Selective retention
Preserve important cached data:Performance impact
Cache hit vs miss
| Scenario | Time | Network | Use Case |
|---|---|---|---|
| Cache hit | ~50ms | None | Instant debugging |
| Cache miss | ~2-5s | Required | First-time fetch |
| Slow RPC | ~10-30s | Required | Rate-limited endpoints |
| Offline | Fails | None | No cached data |
Storage efficiency
Typical sizes:- Transaction envelope: 1-5 KB
- Ledger footprint: 10-100 KB
- Contract WASM: 50-500 KB
- Source map: 20-200 KB
- Simulation results: 5-50 KB
Monitoring cache health
Check for corruption
If you encounter errors loading cached data:Verify file integrity
Manually inspect cache files:Track cache growth
Monitor cache size over time:Troubleshooting
Cache not working
- Check disk space:
df -h - Verify permissions:
ls -la ~/.erst/cache - Create directory manually:
mkdir -p ~/.erst/cache - Check environment variable:
echo $ERST_CACHE_DIR
Cache size incorrect
- Clear cache and rebuild:
erst cache clear --force - Check for filesystem errors:
dmesg | grep -i error - Verify cache directory exists:
ls ~/.erst/cache
Permission denied
- Fix ownership:
sudo chown -R $USER ~/.erst/cache - Fix permissions:
chmod -R 755 ~/.erst/cache - Check SELinux/AppArmor:
sestatusoraa-status
Database locked
- Close other Erst processes
- Remove lock file:
rm ~/.erst/cache.db-shm ~/.erst/cache.db-wal - Wait and retry
Advanced usage
Pre-populate cache
Fetch multiple transactions into cache:Export cache data
Create portable cache archive:Share cache with team
Distribute cache for offline work:Implementation details
Source files
Cache management is implemented in:internal/cache/cache.go- Core cache logicinternal/cmd/cache.go- CLI commandsinternal/rpc/cache.go- RPC-specific caching
Key functions
File cache:Manager.GetCacheSize()- Calculate total cache sizeManager.ListCachedFiles()- List all cached filesManager.Clean()- Run LRU cleanup
CleanByFilter()- Clean with age/network filtersCleanAll()- Clear entire RPC cache
internal/cmd/cache.go:26, internal/cache/cache.go