1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | /**
|
8 | * The cache provides a temporary storage for expirable information. The
|
9 | * primary use of a cache is caching information obtained via costly means
|
10 | * (CPU-heavy computation or networking) to speed up the application's
|
11 | * performance when the same information needs to be retrieved multiple times.
|
12 | *
|
13 | * @interface
|
14 | */
|
15 | class Cache {
|
16 | /**
|
17 | * Clears the cache by deleting all entries.
|
18 | */
|
19 | clear() {}
|
20 | /**
|
21 | * Tests whether the cache contains a fresh entry for the specified key. A
|
22 | * cache entry is fresh if the has not expired its TTL (time to live).
|
23 | *
|
24 | * The method always returns `false` if the cache is currently disabled.
|
25 | *
|
26 | * @param {string} key The identifier of the cache entry.
|
27 | * @return {boolean} `true` if the cache is enabled, the entry exists and has
|
28 | * not expired yet.
|
29 | */
|
30 |
|
31 |
|
32 | has() {}
|
33 | /**
|
34 | * Returns the value of the entry identified by the specified key.
|
35 | *
|
36 | * The method returns `null` if the specified entry does not exist, has
|
37 | * already expired, or the cache is currently disabled.
|
38 | *
|
39 | * @param {string} key The identifier of the cache entry.
|
40 | * @return {*} The value of the specified cache entry, or `null` if the entry
|
41 | * is not available.
|
42 | */
|
43 |
|
44 |
|
45 | get() {}
|
46 | /**
|
47 | * Sets the cache entry identified by the specified key to the provided
|
48 | * value. The entry is created if it does not exist yet.
|
49 | *
|
50 | * The method has no effect if the cache is currently disabled.
|
51 | *
|
52 | * @param {string} key The identifier of the cache entry.
|
53 | * @param {*} value The cache entry value.
|
54 | * @param {?number=} ttl Cache entry time to live in milliseconds. The
|
55 | * entry will expire after the specified amount of milliseconds. Use
|
56 | * `null` or omit the parameter to use the default TTL of this cache.
|
57 | */
|
58 |
|
59 |
|
60 | set() {}
|
61 | /**
|
62 | * Deletes the specified cache entry. The method has no effect if the entry
|
63 | * does not exist.
|
64 | *
|
65 | * @param {string} key The identifier of the cache entry.
|
66 | */
|
67 |
|
68 |
|
69 | delete() {}
|
70 | /**
|
71 | * Disables the cache, preventing the retrieval of any cached entries and
|
72 | * reporting all cache entries as non-existing. Disabling the cache does
|
73 | * not however prevent modifying the existing or creating new cache
|
74 | * entries.
|
75 | *
|
76 | * Disabling the cache also clears all of its current entries.
|
77 | *
|
78 | * The method has no effect if the cache is already disabled.
|
79 | */
|
80 |
|
81 |
|
82 | disable() {}
|
83 | /**
|
84 | * Enables the cache, allowing the retrieval of cache entries.
|
85 | *
|
86 | * The method has no effect if the cache is already enabled.
|
87 | */
|
88 |
|
89 |
|
90 | enable() {}
|
91 | /**
|
92 | * Exports the state of this cache to an HTML-safe JSON string. The data
|
93 | * obtained by parsing the result of this method are compatible with the
|
94 | * {@link Cache#deserialize} method.
|
95 | *
|
96 | * @return {string} A JSON string containing an object representing of the
|
97 | * current state of this cache.
|
98 | */
|
99 |
|
100 |
|
101 | serialize() {}
|
102 | /**
|
103 | * Loads the provided serialized cache data into this cache. Entries
|
104 | * present in this cache but not specified in the provided data will remain
|
105 | * in this cache intact.
|
106 | *
|
107 | * @param {Object<string, {value: *, ttl: number}>} serializedData An
|
108 | * object representing the state of the cache to load, obtained by
|
109 | * parsing the JSON string returned by the {@link Cache#serialize}
|
110 | * method.
|
111 | */
|
112 |
|
113 |
|
114 | deserialize() {}
|
115 |
|
116 | }
|
117 |
|
118 | exports.default = Cache;
|
119 |
|
120 | typeof $IMA !== 'undefined' && $IMA !== null && $IMA.Loader && $IMA.Loader.register('ima/cache/Cache', [], function (_export, _context) {
|
121 | ;
|
122 | return {
|
123 | setters: [],
|
124 | execute: function () {
|
125 | _export('default', exports.default);
|
126 | }
|
127 | };
|
128 | });
|