1 |
|
2 |
|
3 |
|
4 | export class Cache<K, V> {
|
5 | |
6 |
|
7 |
|
8 | constructor(timeout: number);
|
9 | timeout: number;
|
10 | /**
|
11 | * @type list.List<Entry<K, V>>
|
12 | */
|
13 | _q: list.List<Entry<K, V>>;
|
14 | /**
|
15 | * @type {Map<K, Entry<K, V>>}
|
16 | */
|
17 | _map: Map<K, Entry<K, V>>;
|
18 | }
|
19 | export function removeStale<K, V>(cache: Cache<K, V>): number;
|
20 | export function set<K, V>(cache: Cache<K, V>, key: K, value: V): void;
|
21 | export function get<K, V>(cache: Cache<K, V>, key: K): V | undefined;
|
22 | export function refreshTimeout<K, V>(cache: Cache<K, V>, key: K): void;
|
23 | export function getAsync<K, V>(cache: Cache<K, V>, key: K): V | Promise<V> | undefined;
|
24 | export function remove<K, V>(cache: Cache<K, V>, key: K): NonNullable<V> | undefined;
|
25 | export function setIfUndefined<K, V>(cache: Cache<K, V>, key: K, init: () => Promise<V>, removeNull?: boolean): V | Promise<V>;
|
26 | export function create(timeout: number): Cache<any, any>;
|
27 | import * as list from './list.js';
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | declare class Entry<K, V> implements list.ListNode {
|
34 | |
35 |
|
36 |
|
37 |
|
38 | constructor(key: K, val: V | Promise<V>);
|
39 | /**
|
40 | * @type {this | null}
|
41 | */
|
42 | prev: Entry<K, V> | null;
|
43 | |
44 |
|
45 |
|
46 | next: Entry<K, V> | null;
|
47 | created: number;
|
48 | val: V | Promise<V>;
|
49 | key: K;
|
50 | }
|
51 | export {};
|
52 |
|
\ | No newline at end of file |