1 | /** @module cache */
|
2 | /**
|
3 | * Interface for caches that are used to cache values to improve performance.
|
4 | */
|
5 | export interface ICache {
|
6 | /**
|
7 | * Retrieves cached value from the cache using its key.
|
8 | * If value is missing in the cache or expired it returns null.
|
9 | *
|
10 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
11 | * @param key a unique value key.
|
12 | * @param callback callback function that receives cached value or error.
|
13 | */
|
14 | retrieve(correlationId: string, key: string, callback: (err: any, value: any) => void): void;
|
15 | /**
|
16 | * Stores value in the cache with expiration time.
|
17 | *
|
18 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
19 | * @param key a unique value key.
|
20 | * @param value a value to store.
|
21 | * @param timeout expiration timeout in milliseconds.
|
22 | * @param callback (optional) callback function that receives an error or null for success
|
23 | */
|
24 | store(correlationId: string, key: string, value: any, timeout: number, callback?: (err: any) => void): void;
|
25 | /**
|
26 | * Removes a value from the cache by its key.
|
27 | *
|
28 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
29 | * @param key a unique value key.
|
30 | * @param callback (optional) callback function that receives an error or null for success
|
31 | */
|
32 | remove(correlationId: string, key: string, callback?: (err: any) => void): any;
|
33 | }
|