5.1.6 • Published 6 months ago
@types/stale-lru-cache v5.1.6
Installation
npm install --save @types/stale-lru-cache
Summary
This package contains type definitions for stale-lru-cache (https://github.com/cyberthom/stale-lru-cache).
Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/stale-lru-cache.
index.d.ts
// Type definitions for stale-lru-cache 5.1
// Project: https://github.com/cyberthom/stale-lru-cache
// Definitions by: Joona Heikkilä <https://github.com/cxcorp>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Cache<K, V> {
constructor(options?: Cache.CacheOptions<K, V>);
delete(key: K): boolean;
get(key: K): V | undefined;
set(key: K, value: V, options?: string | Cache.SetOptions<K, V>): boolean;
has(key: K): boolean;
isStale(key: K): boolean;
keys(): K[];
reset(): void;
size(): number;
values(): V[];
wrap(
key: K,
revalidate: Cache.RevalidationCallback<K, V>,
callback: Cache.OptionsCallback<K, V>
): void;
}
declare namespace Cache {
type OptionsCallback<K, V> = (error: any, value?: V, options?: string | SetOptions<K, V>) => void;
type RevalidationCallback<K, V> = (key: K, callback: OptionsCallback<K, V>) => void;
interface CacheOptions<K, V> {
maxAge?: number | undefined;
staleWhileRevalidate?: number | undefined;
revalidate?: RevalidationCallback<K, V> | undefined;
maxSize?: number | undefined;
getSize?(value: V, key: K): number;
}
interface SetOptions<K, V> {
maxAge?: number | undefined;
staleWhileRevalidate?: number | undefined;
revalidate?: RevalidationCallback<K, V> | undefined;
}
}
export = Cache;
Additional Details
- Last updated: Fri, 02 Jul 2021 22:32:52 GMT
- Dependencies: none
- Global values: none
Credits
These definitions were written by Joona Heikkilä.