1 |
|
2 | import { IReconfigurable } from 'pip-services3-commons-node';
|
3 | import { ConfigParams } from 'pip-services3-commons-node';
|
4 | import { ICache } from './ICache';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | export declare class MemoryCache implements ICache, IReconfigurable {
|
30 | private _cache;
|
31 | private _count;
|
32 | private _timeout;
|
33 | private _maxSize;
|
34 | |
35 |
|
36 |
|
37 | constructor();
|
38 | /**
|
39 | * Configures component by passing configuration parameters.
|
40 | *
|
41 | * @param config configuration parameters to be set.
|
42 | */
|
43 | configure(config: ConfigParams): void;
|
44 | /**
|
45 | * Clears component state.
|
46 | *
|
47 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
48 | * @param callback callback function that receives error or null no errors occured.
|
49 | */
|
50 | private cleanup;
|
51 | /**
|
52 | * Retrieves cached value from the cache using its key.
|
53 | * If value is missing in the cache or expired it returns null.
|
54 | *
|
55 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
56 | * @param key a unique value key.
|
57 | * @param callback callback function that receives cached value or error.
|
58 | */
|
59 | retrieve(correlationId: string, key: string, callback: (err: any, value: any) => void): void;
|
60 | /**
|
61 | * Stores value in the cache with expiration time.
|
62 | *
|
63 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
64 | * @param key a unique value key.
|
65 | * @param value a value to store.
|
66 | * @param timeout expiration timeout in milliseconds.
|
67 | * @param callback (optional) callback function that receives an error or null for success
|
68 | */
|
69 | store(correlationId: string, key: string, value: any, timeout: number, callback: (err: any, value: any) => void): void;
|
70 | /**
|
71 | * Removes a value from the cache by its key.
|
72 | *
|
73 | * @param correlationId (optional) transaction id to trace execution through call chain.
|
74 | * @param key a unique value key.
|
75 | * @param callback (optional) callback function that receives an error or null for success
|
76 | */
|
77 | remove(correlationId: string, key: string, callback: (err: any) => void): void;
|
78 | }
|