import type { MayBePromise } from './types';
/** The execution context interface */
export interface ExecutionContext {
    waitUntil(promise: Promise<unknown>): void;
}
/** Cache instance map */
export declare const CACHE_INSTANCE_MAP: Map<string, Cache>;
/** A Cache like no-op object */
export declare const CACHE_INTERFACE: Cache;
/**
 * An interface representing options for `cache.serve` method
 */
export interface ServeCacheOptions<K extends RequestInfo | URL> {
    /**
     * The {@link Cache} to use if provided, otherwise uses default
     */
    cache?: Cache;
    /**
     * Preserve headers from response headers being removed
     */
    preserveHeaders?: string[] | ((headerKey: string, headerValue: string, response: Response, cacheStore: Cache, cacheKey: K) => boolean) | boolean;
    /**
     * Indicates whether `Cache-Control should be overwritten`.
     * It also can be a string representing the header value
     *
     * @default true
     */
    overwriteCacheControl?: string | boolean;
}
/** Cache utils */
declare class CacheUtils {
    /** Indicates whether cache is enabled */
    private _enabled;
    /**
     * Indicates whether {@link Cache} api is supported
     * in current environment or not
     */
    get supported(): boolean;
    /**
     * The {@link Cache} instance or a
     * string representing the name of {@link Cache} to be opened
     */
    store: string | Cache;
    /**
     * The `Cache-Control` header to set for asset responses for caching
     *
     * @default 'public, max-age=604800, s-maxage=43200'
     */
    cacheControlHeader: string;
    /** The waitUntil function */
    private _waitUntil?;
    /** Enables cache */
    enable(): void;
    /** Disables cache */
    disable(): void;
    /**
     * Sets execution context
     *
     * Example for Cloudflare workers:
     *
     * ```ts
     * import { cache } from "@cf-wasm/og";
     *
     * export interface Env {}
     *
     * export default {
     *   fetch(req: Request, env: Env, ctx: ExecutionContext) {
     *     cache.setExecutionContext(ctx);
     *
     *     // ...
     *   }
     * }
     * ```
     */
    setExecutionContext(ctx: ExecutionContext): void;
    /**
     * Opens a cache
     *
     * @param cacheName If provided, the name of cache to be opened
     *
     * @returns A promise which resolves to {@link Cache}
     */
    open(cacheName?: string): Promise<Cache>;
    /**
     * Serve cached assets
     *
     * @param key The cache key
     * @param fallback The fallback function which provides the {@link Response} when cache key is not matched
     * @param param2 Options
     *
     * @returns A promise which resolves to {@link Response}
     */
    serve<K extends RequestInfo | URL, F extends (cacheKey: K, cacheStore: Cache) => MayBePromise<Response | undefined>>(key: K, fallback: F, { cache: cacheStore, preserveHeaders, overwriteCacheControl }?: ServeCacheOptions<K>): Promise<Awaited<ReturnType<F>>>;
}
export declare const cache: CacheUtils;
export {};
