Overview
The tif1 library uses a high-performance SQLite-backed cache with in-memory LRU caching to minimize network requests and dramatically improve data access speed. Caching is enabled by default and requires no configuration.How Caching Works
The cache system uses a two-tier architecture:-
In-Memory LRU Cache: Fast access to recently used data
- Laps and session data: 1,024 items (configurable)
- Telemetry data: 2,048 items (configurable)
-
SQLite Persistent Cache: Disk-based storage for all fetched data
- Uses WAL (Write-Ahead Logging) mode for better concurrency
- Automatically compresses data with gzip
- Stores data at
~/.cache/tif1/(Linux),~/Library/Caches/tif1/(macOS), or%LOCALAPPDATA%/Temp/tif1(Windows)
Cache Location
Get the cache directory location:Cache Benefits
Caching provides significant performance improvements:Checking Cache Status
Inspect cache size and contents:Disabling Cache
Disable caching for specific sessions:Clearing Cache
Clear all cached data:Cache Management Best Practices
When to Clear Cache
- Testing new features: Clear cache to ensure fresh data
- Data updates: If you know F1 data has been updated
- Disk space: Free up storage when needed
- Debugging: Eliminate cache as a variable
When to Disable Cache
- One-time queries: For scripts that run once and exit
- Testing: When you want to ensure fresh data every time
- Limited disk space: When persistent storage isn’t available
- CI/CD pipelines: Depending on your caching strategy
Optimal Cache Usage
Custom Cache Directory
Change cache location via environment variable:Cache Configuration
Configure cache behavior via.tif1rc file:
cache_dir: Cache directory pathenable_cache: Enable/disable caching globallycache_commit_interval: SQLite commit frequency (number of writes)sqlite_timeout: SQLite lock timeout in secondsmemory_cache_max_items: Max items in memory cache for laps/sessionsmemory_telemetry_cache_max_items: Max items in memory cache for telemetry
Cache Performance Tuning
For advanced users, tune cache performance:Offline Mode
Use cached data exclusively without network requests:Complete Cache Management Example
Next Steps
- Learn about configuration for more cache settings
- Explore async loading for faster initial data fetching
- Understand error handling for cache-related errors