UNPKG

@push.rocks/webrequest

Version:

Modern, fetch-compatible web request library with intelligent HTTP caching, retry strategies, and fault tolerance.

55 lines (54 loc) 1.44 kB
/** * Cache storage layer using IndexedDB via @push.rocks/webstore */ import type { ICacheEntry } from '../webrequest.types.js'; export declare class CacheStore { private webstore; private initPromise; constructor(dbName?: string, storeName?: string); /** * Initialize the store */ private init; /** * Generate a cache key from a request */ generateCacheKey(request: Request): string; /** * Store a response in the cache */ set(cacheKey: string, entry: ICacheEntry): Promise<void>; /** * Retrieve a cached response */ get(cacheKey: string): Promise<ICacheEntry | null>; /** * Check if a cache entry exists */ has(cacheKey: string): Promise<boolean>; /** * Delete a cache entry */ delete(cacheKey: string): Promise<void>; /** * Clear all cache entries */ clear(): Promise<void>; /** * Create a Response object from a cache entry */ responseFromCacheEntry(entry: ICacheEntry): Response; /** * Create a cache entry from a Response object */ cacheEntryFromResponse(url: string, response: Response, metadata?: { maxAge?: number; etag?: string; lastModified?: string; }): Promise<ICacheEntry>; /** * Prune expired entries (garbage collection) * Returns the number of entries deleted */ pruneExpired(): Promise<number>; }