@jupyterlab/coreutils
Version: 
JupyterLab - Core Utilities
28 lines (27 loc) • 693 B
TypeScript
/** A least-recently-used cache. */
export declare class LruCache<T, U> {
    protected _map: Map<T, U>;
    protected _maxSize: number;
    constructor(options?: LruCache.IOptions);
    /**
     * Return the current size of the cache.
     */
    get size(): number;
    /**
     * Clear the values in the cache.
     */
    clear(): void;
    /**
     * Get a value (or null) from the cache, pushing the item to the front of the cache.
     */
    get(key: T): U | null;
    /**
     * Set a value in the cache, potentially evicting an old item.
     */
    set(key: T, value: U): void;
}
export declare namespace LruCache {
    interface IOptions {
        maxSize?: number | null;
    }
}