import { SWRListener } from './events';
import { SWRKey } from './key';
/**
 * Default cache removal options.
 */
export declare const defaultCacheRemoveOptions: CacheRemoveOptions;
/**
 * Default cache clear options.
 */
export declare const defaultCacheClearOptions: CacheClearOptions;
/**
 * Determines how a cache item data looks like.
 */
export interface CacheItemData<D> {
    /**
     * Determines the data that's stored in the cache.
     */
    data: D | Promise<D>;
    /**
     * Determines the expiration date for the given set of data.
     */
    expiresAt?: Date | null;
}
/**
 * Determines the type of the cache items.
 */
export declare class CacheItem<D = unknown> {
    /**
     * Determines the data that's stored in the cache.
     */
    data: D | Promise<D>;
    /**
     * Determines the expiration date for the given set of data.
     */
    expiresAt: Date | null;
    /**
     * Creates the cache item given the data and expiration at.
     */
    constructor({ data, expiresAt }: CacheItemData<D>);
    /**
     * Determines if the current cache item is still being resolved.
     * This returns true if data is a promise, or false if type `D`.
     */
    isResolving(): boolean;
    /**
     * Determines if the given cache item has expired.
     */
    hasExpired(): boolean;
    /**
     * Set the expiration time of the given cache item relative to now.
     */
    expiresIn(milliseconds: number): this;
}
/**
 * Determines the cache item removal options.
 */
export interface CacheRemoveOptions {
    /**
     * Determines if the cache should broadcast the cache
     * change to subscribed handlers. That means telling them
     * the value now resolves to undefined.
     */
    broadcast: boolean;
}
/**
 * Determines the cache clear options.
 */
export interface CacheClearOptions extends CacheRemoveOptions {
}
/**
 * Represents the methods a cache should implement
 * in order to be usable by vue-swr.
 */
export interface SWRCache {
    /**
     * Gets an item from the cache.
     */
    get<D>(key: SWRKey): CacheItem<D>;
    /**
     * Sets an item to the cache.
     */
    set<D>(key: SWRKey, value: CacheItem<D>): void;
    /**
     * Removes a key-value pair from the cache.
     */
    remove(key: SWRKey, options?: Partial<CacheRemoveOptions>): void;
    /**
     * Removes all the key-value pairs from the cache.
     */
    clear(options?: Partial<CacheClearOptions>): void;
    /**
     * Determines if the cache has a given key.
     */
    has(key: SWRKey): boolean;
    /**
     * Subscribes to the given key for changes.
     */
    subscribe(key: SWRKey, listener: SWRListener): void;
    /**
     * Unsubscribes to the given key events.
     */
    unsubscribe(key: SWRKey, listener: SWRListener): void;
    /**
     * Broadcasts a value change to all subscribed instances.
     */
    broadcast<D>(key: SWRKey, detail: D): void;
}
/**
 * Default cache implementation for vue-cache.
 */
export declare class DefaultCache implements SWRCache {
    /**
     * Stores the elements of the cache in a key-value pair.
     */
    private elements;
    /**
     * Stores the event target instance to dispatch and receive events.
     */
    private event;
    /**
     * Resolves the promise and replaces the Promise to the resolved data.
     * It also broadcasts the value change if needed or deletes the key if
     * the value resolves to undefined or null.
     */
    private resolve;
    /**
     * Gets an element from the cache.
     *
     * It is assumed the item always exist when
     * you get it. Use the has method to check
     * for the existence of it.
     */
    get<D>(key: string): CacheItem<D>;
    /**
     * Sets an element to the cache.
     */
    set<D>(key: SWRKey, value: CacheItem<D>): void;
    /**
     * Removes an key-value pair from the cache.
     */
    remove(key: SWRKey, options?: Partial<CacheRemoveOptions>): void;
    /**
     * Removes all the key-value pairs from the cache.
     */
    clear(options?: Partial<CacheClearOptions>): void;
    /**
     * Determines if the given key exists
     * in the cache.
     */
    has(key: SWRKey): boolean;
    /**
     * Subscribes the callback to the given key.
     */
    subscribe(key: SWRKey, listener: SWRListener): void;
    /**
     * Unsubscribes to the given key events.
     */
    unsubscribe(key: SWRKey, listener: SWRListener): void;
    /**
     * Broadcasts a value change  on all subscribed instances.
     */
    broadcast<D>(key: SWRKey, data: D): void;
}
