import { Observable } from 'rxjs';
import { ODataRequest, ODataResponse } from '../resources';
import { Cache } from '../types';
/**
 * A cache entry that holds a payload, a last read time, and a timeout for the entry.
 * @param payload The payload to cache.
 * @param lastRead The last read time.
 * @param timeout The timeout.
 * @param tags Some tags to identify the entry.
 */
export interface ODataCacheEntry<T> {
    payload: T;
    lastRead: number;
    timeout: number;
    tags: string[];
}
export declare abstract class ODataCache implements Cache {
    timeout: number;
    entries: Map<string, ODataCacheEntry<any>>;
    constructor({ timeout }: {
        timeout?: number;
    });
    abstract getResponse(req: ODataRequest<any>): ODataResponse<any> | undefined;
    abstract putResponse(req: ODataRequest<any>, res: ODataResponse<any>): void;
    /**
     * Using the resource on the request build an array of string to identify the scope of the request
     * @param req The request with the resource to build the scope
     * @returns Array of string to identify the scope of the request
     */
    scope(req: ODataRequest<any>): string[];
    /**
     * Using the odata context on the response build an array of string to identify the tags of the response
     * @param res The response to build the tags
     * @returns Array of string to identify the tags of the response
     */
    tags(res: ODataResponse<any>): string[];
    /**
     * Build an entry from a payload and some options
     * @param payload The payload to store in the cache
     * @param timeout The timeout for the entry
     * @param tags The tags for the entry
     * @returns The entry to store in the cache
     */
    buildEntry<T>(payload: T, { timeout, tags }: {
        timeout?: number;
        tags?: string[];
    }): ODataCacheEntry<T>;
    /**
     * Build a key from store an entry in the cache
     * @param names The names of the entry
     * @returns The key for the entry
     */
    buildKey(names: string[]): string;
    /**
     * Put some payload in the cache
     * @param name The name for the entry
     * @param payload The payload to store in the cache
     * @param timeout The timeout for the entry
     * @param scope The scope for the entry
     * @param tags The tags for the entry
     */
    put<T>(name: string, payload: T, { timeout, scope, tags, }?: {
        timeout?: number;
        scope?: string[];
        tags?: string[];
    }): void;
    /**
     * Return the payload from the cache if it exists and is not expired
     * @param name The name of the entry
     * @param scope The scope of the entry
     * @returns The payload of the entry
     */
    get<T>(name: string, { scope }?: {
        scope?: string[];
    }): T;
    /**
     * Remove all cache entries that are matching with the given options
     * @param options The options to forget
     */
    forget({ name, scope, tags, }?: {
        name?: string;
        scope?: string[];
        tags?: string[];
    }): void;
    /**
     * Remove all cache entries
     */
    flush(): void;
    /**
     * Check if the entry is expired
     * @param entry The cache entry
     * @returns Boolean indicating if the entry is expired
     */
    isExpired(entry: ODataCacheEntry<any>): boolean;
    /**
     * Using the request, handle the fetching of the response
     * @param req The request to fetch
     * @param res$ Observable of the response
     * @returns
     */
    handleRequest(req: ODataRequest<any>, res$: Observable<ODataResponse<any>>): Observable<ODataResponse<any>>;
    private handleFetch;
    private handleMutate;
}
