@thi.ng/cache
Version:
In-memory cache implementations with ES6 Map-like API and different eviction strategies
31 lines • 1.42 kB
TypeScript
import type { Fn0, Maybe, Nullable } from "@thi.ng/api";
import type { ConsCell } from "@thi.ng/dcons";
import { DCons } from "@thi.ng/dcons/dcons";
import type { CacheEntry, CacheOpts, ICache, MapLike } from "./api.js";
export declare class LRUCache<K, V> implements ICache<K, V> {
protected map: MapLike<K, ConsCell<CacheEntry<K, V>>>;
protected items: DCons<CacheEntry<K, V>>;
protected opts: CacheOpts<K, V>;
protected _size: number;
constructor(pairs?: Nullable<Iterable<[K, V]>>, opts?: Partial<CacheOpts<K, V>>);
get length(): number;
get size(): number;
[Symbol.iterator](): IterableIterator<readonly [K, CacheEntry<K, V>]>;
entries(): IterableIterator<Readonly<[K, CacheEntry<K, V>]>>;
keys(): IterableIterator<Readonly<K>>;
values(): IterableIterator<Readonly<V>>;
copy(): ICache<K, V>;
empty(): LRUCache<K, V>;
release(): boolean;
has(key: K): boolean;
get(key: K, notFound?: V): V | undefined;
set(key: K, value: V): V;
into(pairs: Iterable<[K, V]>): this;
getSet(key: K, retrieve: Fn0<Promise<V>>): Promise<V>;
delete(key: K): boolean;
protected resetEntry(e: ConsCell<CacheEntry<K, V>>): V;
protected ensureSize(): boolean;
protected removeEntry(e: ConsCell<CacheEntry<K, V>>): void;
protected doSetEntry(e: Maybe<ConsCell<CacheEntry<K, V>>>, k: K, v: V, s: number): void;
}
//# sourceMappingURL=lru.d.ts.map