Skip to main content
Erst maintains a local cache of transaction data and simulation results to improve performance and enable offline analysis. This guide covers cache configuration, maintenance, and optimization strategies.

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
Caching provides:
  • 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:
Customize with environment variable:
The cache directory is created automatically on first use.

Cache commands

Check cache status

View cache size and usage statistics:
Example output:
If cache exceeds the limit:

Clean old entries

Remove old cached files using LRU (Least Recently Used) strategy:
What happens:
Skip confirmation:

Clear all cache

Delete all cached files:
This action cannot be undone. All cached transaction data will be permanently deleted.
Skip confirmation:

RPC cache management

Erst also maintains a separate SQLite database for RPC fetch results:
This cache stores network responses for:
  • Transaction envelopes
  • Ledger entries
  • Contract code
  • Network metadata

Clean RPC cache by age

Remove entries older than N days:
Example: Remove all entries older than 7 days.

Clean RPC cache by network

Remove entries for a specific network:
Useful when:
  • 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 in internal/cache/cache.go:

LRU strategy

When cleaning, Erst:
  1. Lists all cached files with access times
  2. Sorts by least recently used
  3. Deletes files until size drops to 50% of maximum
  4. 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:
Cleans entries older than 30 days every Sunday.

Network-specific cleanup

After testnet resets:

Disk space management

If running low on disk space:

Selective retention

Preserve important cached data:

Performance impact

Cache hit vs miss

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
100 cached transactions ≈ 10-100 MB 1000 cached transactions ≈ 100 MB - 1 GB

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

Solutions:
  • 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

Solutions:
  • 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

Solutions:
  • Fix ownership: sudo chown -R $USER ~/.erst/cache
  • Fix permissions: chmod -R 755 ~/.erst/cache
  • Check SELinux/AppArmor: sestatus or aa-status

Database locked

Solutions:
  • 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 logic
  • internal/cmd/cache.go - CLI commands
  • internal/rpc/cache.go - RPC-specific caching

Key functions

File cache:
  • Manager.GetCacheSize() - Calculate total cache size
  • Manager.ListCachedFiles() - List all cached files
  • Manager.Clean() - Run LRU cleanup
RPC cache:
  • CleanByFilter() - Clean with age/network filters
  • CleanAll() - Clear entire RPC cache
Location: internal/cmd/cache.go:26, internal/cache/cache.go

Next steps

Working with sessions

Sessions complement caching for persistent debugging

Debugging failed transactions

Learn how caching speeds up transaction debugging

Local WASM replay

Test locally without relying on cached network data