cf-workers-query
Version:
Automatically cache and revalidate data in Cloudflare Workers. Using the Cache API and Execution Context
31 lines (27 loc) • 1.02 kB
TypeScript
import { Q as QueryKey } from './create-query-B9ILJCq6.js';
export { C as CacheApiAdaptor, c as createQuery } from './create-query-B9ILJCq6.js';
/**
* Best-effort deduplication manager for query execution.
*
* Uses a short-lived "processing" marker in Cache API to signal
* that a query is already being fetched. This is not atomic
* (CF Cache API has no CAS operations) but dramatically reduces
* redundant work in practice.
*/
declare class DedupeManager {
private cache;
constructor(cacheName?: string);
/**
* Check if someone is already processing this key.
* Best-effort: small race window exists between check and mark.
*/
isProcessing(key: QueryKey): Promise<boolean>;
markProcessing(key: QueryKey): Promise<void>;
clearProcessing(key: QueryKey): Promise<void>;
private buildMarkerKey;
}
declare const invalidateQuery: ({ queryKey, cacheName, }: {
queryKey: QueryKey;
cacheName?: string;
}) => Promise<void>;
export { DedupeManager, invalidateQuery };