Factory function that creates a cache plugin for FetchEngine.
The plugin creates its own SingleFlight for cache storage and installs beforeRequest (priority -20) and afterRequest (priority -10) hooks.
SingleFlight
beforeRequest
afterRequest
Cache configuration
Object with FetchPlugin interface plus cache management methods
const cache = cachePlugin({ ttl: 300000, staleIn: 60000 }); const api = new FetchEngine({ baseUrl: 'https://api.example.com', plugins: [cache] }); // Access cache methods directly on the plugin cache.clearCache(); cache.stats(); Copy
const cache = cachePlugin({ ttl: 300000, staleIn: 60000 }); const api = new FetchEngine({ baseUrl: 'https://api.example.com', plugins: [cache] }); // Access cache methods directly on the plugin cache.clearCache(); cache.stats();
Factory function that creates a cache plugin for FetchEngine.
The plugin creates its own
SingleFlightfor cache storage and installsbeforeRequest(priority -20) andafterRequest(priority -10) hooks.