1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | import { MinimalCancelToken } from './cancel-token';
|
15 |
|
16 |
|
17 |
|
18 | export declare class AsyncWorkCache<K, V> {
|
19 | private _keyToResultMap;
|
20 | constructor(from?: AsyncWorkCache<K, V>);
|
21 | /**
|
22 | * If work has already begun to compute the given key, return a promise for
|
23 | * the result of that work.
|
24 | *
|
25 | * If not, compute it with the given function.
|
26 | *
|
27 | * This method ensures that, in the absence of cancellations, we will only try
|
28 | * to compute the value for `key` once, no matter how often or with what
|
29 | * timing getOrCompute is called, even recursively.
|
30 | *
|
31 | * This API is safe for multiple, independently cancellable callers. So long
|
32 | * as the given cancelToken is not cancelled, this function will not reject
|
33 | * with a Cancel exception.
|
34 | */
|
35 | getOrCompute(key: K, compute: () => Promise<V>, cancelToken?: MinimalCancelToken): Promise<V>;
|
36 | private _getOrCompute;
|
37 | delete(key: K): void;
|
38 | clear(): void;
|
39 | set(key: K, value: V): void;
|
40 | has(key: K): boolean;
|
41 | }
|