import { SimpleLoggerInterface, SimpleLogLevels } from "ts-simple-interfaces";
declare type CacheConfig = {
    maxLength: number;
    ttlSec: number;
};
declare type Timeout = any;
export declare class Cache {
    protected _log?: SimpleLoggerInterface | undefined;
    protected config: CacheConfig;
    protected _cache: {
        [queryKey: string]: {
            t: number;
            v: unknown;
            ttl: Timeout | null;
        };
    };
    private _groomingCache;
    constructor(config: Partial<CacheConfig>, _log?: SimpleLoggerInterface | undefined);
    /**
     * Public method to clear the cache
     *
     * This may be used in an administrative endpoint when, for example, the database is manually
     * manipulated, or it may be used internally to clear a specific key on change.
     */
    clear(key?: string | RegExp): void;
    /**
     * Return the value stored at the given key, or execute the given query, storing its return
     * value at the given key if not already set.
     */
    get<T>(key: string): T | undefined;
    get<T>(key: string, q: () => T, ttlSec?: number): Promise<T>;
    get<T>(key: string, q: () => Promise<T>, ttlSec?: number): Promise<T>;
    /**
     * Remove old values if cache is getting too long
     */
    protected groomCache(): Promise<void>;
    /**
     * Log at a given log level, if logger is available
     */
    protected log(level: keyof SimpleLogLevels, msg: string): void;
}
export {};
