Warm Cache
Keep capacity data hot with a background poller. Eliminates cold-start penalty on your first call.
Usage
What Gets Cached
| Data | Without Warm Cache | With Warm Cache |
|---|---|---|
| Borrowing capacity | ~20ms (API call) | Instant |
| Token routes | ~20ms (API call) | Instant |
| Fee quotes | ~20ms (API call) | Instant |
| Protocol health | ~20ms (API call) | Instant |
โน๏ธ Note
The poller runs every 2 seconds in the background. Data is always fresh for MEV/arbitrage use cases.Advanced API
For bots that need direct access to the Warm Cache instance:
| Method | Returns | Description |
|---|---|---|
start() | Promise<void> | Start polling โ first refresh is synchronous |
stop() | void | Stop background polling |
isWarm() | boolean | Whether cache has data loaded |
getCapacity() | CapacityResponse | null | Get all cached capacity data |
getTokenCapacity(symbol) | TokenCapacity | null | Get capacity for a single token |
onUpdate(handler) | void | Register a listener for capacity updates |
๐ก Tip
Always call cache.stop() / flash.destroy() when shutting down to stop the background poller and prevent resource leaks.