Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sebamar88/bytekit/llms.txt
Use this file to discover all available pages before exploring further.
Powered by Mintlify
Auto-generate your docs
HTTP request caching with TTL support
Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sebamar88/bytekit/llms.txt
Use this file to discover all available pages before exploring further.
import { RequestCache } from "bytekit";
// or
import { RequestCache } from "bytekit/request-cache";
const cache = new RequestCache({
ttl: 60000, // 1 minute
maxSize: 100
});
// Set cache entry
cache.set("/users", responseData, { ttl: 120000 });
// Get cache entry
const cached = cache.get("/users");
// Clear cache
cache.clear();
import { ApiClient, RequestCache } from "bytekit";
const cache = new RequestCache({ ttl: 60000 });
const api = new ApiClient({
baseUrl: "https://api.example.com",
interceptors: {
request: async (url, init) => {
const cached = cache.get(url);
if (cached) {
return [url, { ...init, signal: AbortSignal.abort() }];
}
return [url, init];
},
response: async (response) => {
const data = await response.clone().json();
cache.set(response.url, data);
return response;
}
}
});