cacheable 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -17,16 +17,58 @@ declare class CacheableStats {
17
17
  private _count;
18
18
  private _enabled;
19
19
  constructor(options?: CacheableOptions$1);
20
+ /**
21
+ * @returns {boolean} - Whether the stats are enabled
22
+ */
20
23
  get enabled(): boolean;
24
+ /**
25
+ * @param {boolean} enabled - Whether to enable the stats
26
+ */
21
27
  set enabled(enabled: boolean);
28
+ /**
29
+ * @returns {number} - The number of hits
30
+ * @readonly
31
+ */
22
32
  get hits(): number;
33
+ /**
34
+ * @returns {number} - The number of misses
35
+ * @readonly
36
+ */
23
37
  get misses(): number;
38
+ /**
39
+ * @returns {number} - The number of gets
40
+ * @readonly
41
+ */
24
42
  get gets(): number;
43
+ /**
44
+ * @returns {number} - The number of sets
45
+ * @readonly
46
+ */
25
47
  get sets(): number;
48
+ /**
49
+ * @returns {number} - The number of deletes
50
+ * @readonly
51
+ */
26
52
  get deletes(): number;
53
+ /**
54
+ * @returns {number} - The number of clears
55
+ * @readonly
56
+ */
27
57
  get clears(): number;
58
+ /**
59
+ * @returns {number} - The vsize (value size) of the cache instance
60
+ * @readonly
61
+ */
28
62
  get vsize(): number;
63
+ /**
64
+ * @returns {number} - The ksize (key size) of the cache instance
65
+ * @readonly
66
+ */
29
67
  get ksize(): number;
68
+ /**
69
+ * @returns {number} - The count of the cache instance
70
+ * @readonly
71
+ */
30
72
  get count(): number;
31
73
  incrementHits(): void;
32
74
  incrementMisses(): void;
@@ -47,6 +89,15 @@ declare class CacheableStats {
47
89
  resetStoreValues(): void;
48
90
  }
49
91
 
92
+ /**
93
+ * CacheableItem
94
+ * @typedef {Object} CacheableItem
95
+ * @property {string} key - The key of the cacheable item
96
+ * @property {any} value - The value of the cacheable item
97
+ * @property {number|string} [ttl] - Time to Live - If you set a number it is miliseconds, if you set a string it is a human-readable
98
+ * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that it will use the default time-to-live. If both are
99
+ * undefined then it will not have a time-to-live.
100
+ */
50
101
  type CacheableItem = {
51
102
  key: string;
52
103
  value: any;
@@ -58,6 +109,33 @@ type CacheableStoreItem = {
58
109
  expires?: number;
59
110
  };
60
111
 
112
+ type WrapOptions = {
113
+ ttl?: number | string;
114
+ keyPrefix?: string;
115
+ cache: Cacheable;
116
+ };
117
+ type WrapSyncOptions = {
118
+ ttl?: number | string;
119
+ keyPrefix?: string;
120
+ cache: CacheableMemory;
121
+ };
122
+ type WrapFunctionOptions = {
123
+ ttl?: number | string;
124
+ keyPrefix: string;
125
+ };
126
+ type AnyFunction = (...arguments_: any[]) => any;
127
+ declare function wrapSync<T>(function_: AnyFunction, options: WrapSyncOptions): AnyFunction;
128
+ declare function wrap<T>(function_: AnyFunction, options: WrapOptions): AnyFunction;
129
+
130
+ /**
131
+ * @typedef {Object} CacheableMemoryOptions
132
+ * @property {number|string} [ttl] - Time to Live - If you set a number it is miliseconds, if you set a string it is a human-readable
133
+ * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that it will use the default time-to-live. If both are
134
+ * undefined then it will not have a time-to-live.
135
+ * @property {boolean} [useClone] - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true.
136
+ * @property {number} [lruSize] - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0.
137
+ * @property {number} [checkInterval] - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0.
138
+ */
61
139
  type CacheableMemoryOptions = {
62
140
  ttl?: number | string;
63
141
  useClone?: boolean;
@@ -65,6 +143,7 @@ type CacheableMemoryOptions = {
65
143
  checkInterval?: number;
66
144
  };
67
145
  declare class CacheableMemory {
146
+ private _lru;
68
147
  private readonly _hashCache;
69
148
  private readonly _hash0;
70
149
  private readonly _hash1;
@@ -76,60 +155,238 @@ declare class CacheableMemory {
76
155
  private readonly _hash7;
77
156
  private readonly _hash8;
78
157
  private readonly _hash9;
79
- private readonly _lru;
80
158
  private _ttl;
81
159
  private _useClone;
82
160
  private _lruSize;
83
161
  private _checkInterval;
84
162
  private _interval;
163
+ /**
164
+ * @constructor
165
+ * @param {CacheableMemoryOptions} [options] - The options for the CacheableMemory
166
+ */
85
167
  constructor(options?: CacheableMemoryOptions);
168
+ /**
169
+ * Gets the time-to-live
170
+ * @returns {number|string|undefined} - The time-to-live in miliseconds or a human-readable format. If undefined, it will not have a time-to-live.
171
+ */
86
172
  get ttl(): number | string | undefined;
173
+ /**
174
+ * Sets the time-to-live
175
+ * @param {number|string|undefined} value - The time-to-live in miliseconds or a human-readable format (example '1s' = 1 second, '1h' = 1 hour). If undefined, it will not have a time-to-live.
176
+ */
87
177
  set ttl(value: number | string | undefined);
178
+ /**
179
+ * Gets whether to use clone
180
+ * @returns {boolean} - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true.
181
+ */
88
182
  get useClone(): boolean;
183
+ /**
184
+ * Sets whether to use clone
185
+ * @param {boolean} value - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true.
186
+ */
89
187
  set useClone(value: boolean);
188
+ /**
189
+ * Gets the size of the LRU cache
190
+ * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0.
191
+ */
90
192
  get lruSize(): number;
193
+ /**
194
+ * Sets the size of the LRU cache
195
+ * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0.
196
+ */
91
197
  set lruSize(value: number);
198
+ /**
199
+ * Gets the check interval
200
+ * @returns {number} - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0.
201
+ */
92
202
  get checkInterval(): number;
203
+ /**
204
+ * Sets the check interval
205
+ * @param {number} value - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0.
206
+ */
93
207
  set checkInterval(value: number);
208
+ /**
209
+ * Gets the size of the cache
210
+ * @returns {number} - The size of the cache
211
+ */
94
212
  get size(): number;
213
+ /**
214
+ * Gets the keys
215
+ * @returns {IterableIterator<string>} - The keys
216
+ */
95
217
  get keys(): IterableIterator<string>;
218
+ /**
219
+ * Gets the items
220
+ * @returns {IterableIterator<CacheableStoreItem>} - The items
221
+ */
96
222
  get items(): IterableIterator<CacheableStoreItem>;
223
+ /**
224
+ * Gets the value of the key
225
+ * @param {string} key - The key to get the value
226
+ * @returns {T | undefined} - The value of the key
227
+ */
97
228
  get<T>(key: string): T | undefined;
229
+ /**
230
+ * Gets the values of the keys
231
+ * @param {string[]} keys - The keys to get the values
232
+ * @returns {T[]} - The values of the keys
233
+ */
98
234
  getMany<T>(keys: string[]): T[];
235
+ /**
236
+ * Gets the raw value of the key
237
+ * @param {string} key - The key to get the value
238
+ * @returns {CacheableStoreItem | undefined} - The raw value of the key
239
+ */
99
240
  getRaw(key: string): CacheableStoreItem | undefined;
241
+ /**
242
+ * Gets the raw values of the keys
243
+ * @param {string[]} keys - The keys to get the values
244
+ * @returns {CacheableStoreItem[]} - The raw values of the keys
245
+ */
100
246
  getManyRaw(keys: string[]): Array<CacheableStoreItem | undefined>;
247
+ /**
248
+ * Sets the value of the key
249
+ * @param {string} key - The key to set the value
250
+ * @param {any} value - The value to set
251
+ * @param {number|string} [ttl] - Time to Live - If you set a number it is miliseconds, if you set a string it is a human-readable.
252
+ * If you set undefined, it will use the default time-to-live. If both are undefined then it will not have a time-to-live.
253
+ * @returns {void}
254
+ */
101
255
  set(key: string, value: any, ttl?: number | string): void;
256
+ /**
257
+ * Sets the values of the keys
258
+ * @param {CacheableItem[]} items - The items to set
259
+ * @returns {void}
260
+ */
102
261
  setMany(items: CacheableItem[]): void;
262
+ /**
263
+ * Checks if the key exists
264
+ * @param {string} key - The key to check
265
+ * @returns {boolean} - If true, the key exists. If false, the key does not exist.
266
+ */
103
267
  has(key: string): boolean;
104
- take<T>(key: string): any;
105
- takeMany<T>(keys: string[]): any[];
268
+ /**
269
+ * @function hasMany
270
+ * @param {string[]} keys - The keys to check
271
+ * @returns {boolean[]} - If true, the key exists. If false, the key does not exist.
272
+ */
273
+ hasMany(keys: string[]): boolean[];
274
+ /**
275
+ * Take will get the key and delete the entry from cache
276
+ * @param {string} key - The key to take
277
+ * @returns {T | undefined} - The value of the key
278
+ */
279
+ take<T>(key: string): T | undefined;
280
+ /**
281
+ * TakeMany will get the keys and delete the entries from cache
282
+ * @param {string[]} keys - The keys to take
283
+ * @returns {T[]} - The values of the keys
284
+ */
285
+ takeMany<T>(keys: string[]): T[];
286
+ /**
287
+ * Delete the key
288
+ * @param {string} key - The key to delete
289
+ * @returns {void}
290
+ */
106
291
  delete(key: string): void;
292
+ /**
293
+ * Delete the keys
294
+ * @param {string[]} keys - The keys to delete
295
+ * @returns {void}
296
+ */
107
297
  deleteMany(keys: string[]): void;
298
+ /**
299
+ * Clear the cache
300
+ * @returns {void}
301
+ */
108
302
  clear(): void;
303
+ /**
304
+ * Get the store based on the key (internal use)
305
+ * @param {string} key - The key to get the store
306
+ * @returns {CacheableHashStore} - The store
307
+ */
308
+ getStore(key: string): Map<string, CacheableStoreItem>;
309
+ /**
310
+ * Get the store based on the hash (internal use)
311
+ * @param {number} hash
312
+ * @returns {Map<string, CacheableStoreItem>}
313
+ */
314
+ getStoreFromHash(hash: number): Map<string, CacheableStoreItem>;
315
+ /**
316
+ * Hash the key (internal use)
317
+ * @param key
318
+ * @returns {number} from 0 to 9
319
+ */
109
320
  hashKey(key: string): number;
110
- getStore(key: string): Map<string, any>;
321
+ /**
322
+ * Clone the value. This is for internal use
323
+ * @param {any} value - The value to clone
324
+ * @returns {any} - The cloned value
325
+ */
111
326
  clone(value: any): any;
327
+ /**
328
+ * Add to the front of the LRU cache. This is for internal use
329
+ * @param {string} key - The key to add to the front
330
+ * @returns {void}
331
+ */
112
332
  lruAddToFront(key: string): void;
333
+ /**
334
+ * Move to the front of the LRU cache. This is for internal use
335
+ * @param {string} key - The key to move to the front
336
+ * @returns {void}
337
+ */
113
338
  lruMoveToFront(key: string): void;
339
+ /**
340
+ * Resize the LRU cache. This is for internal use
341
+ * @returns {void}
342
+ */
114
343
  lruResize(): void;
344
+ /**
345
+ * Check for expiration. This is for internal use
346
+ * @returns {void}
347
+ */
115
348
  checkExpiration(): void;
349
+ /**
350
+ * Start the interval check. This is for internal use
351
+ * @returns {void}
352
+ */
116
353
  startIntervalCheck(): void;
354
+ /**
355
+ * Stop the interval check. This is for internal use
356
+ * @returns {void}
357
+ */
117
358
  stopIntervalCheck(): void;
359
+ /**
360
+ * Hash the object. This is for internal use
361
+ * @param {any} object - The object to hash
362
+ * @param {string} [algorithm='sha256'] - The algorithm to hash
363
+ * @returns {string} - The hashed string
364
+ */
118
365
  hash(object: any, algorithm?: string): string;
119
- wrap<T>(function_: (...arguments_: any[]) => T, options?: {
120
- ttl?: number;
121
- key?: string;
122
- }): (...arguments_: any[]) => T;
366
+ /**
367
+ * Wrap the function for caching
368
+ * @param {Function} function_ - The function to wrap
369
+ * @param {Object} [options] - The options to wrap
370
+ * @returns {Function} - The wrapped function
371
+ */
372
+ wrap<T>(function_: (...arguments_: any[]) => T, options: WrapFunctionOptions): (...arguments_: any[]) => T;
123
373
  private isPrimitive;
124
374
  private concatStores;
125
375
  private setTtl;
126
376
  }
127
377
 
378
+ type KeyvCacheableMemoryOptions = CacheableMemoryOptions & {
379
+ namespace?: string;
380
+ };
128
381
  declare class KeyvCacheableMemory implements KeyvStoreAdapter {
129
382
  opts: CacheableMemoryOptions;
130
- namespace?: string | undefined;
131
- private readonly _cache;
132
- constructor(options?: CacheableMemoryOptions);
383
+ private readonly _defaultCache;
384
+ private readonly _nCache;
385
+ private _namespace?;
386
+ constructor(options?: KeyvCacheableMemoryOptions);
387
+ get namespace(): string | undefined;
388
+ set namespace(value: string | undefined);
389
+ get store(): CacheableMemory;
133
390
  get<Value>(key: string): Promise<StoredData<Value> | undefined>;
134
391
  getMany<Value>(keys: string[]): Promise<Array<StoredData<Value | undefined>>>;
135
392
  set(key: string, value: any, ttl?: number): Promise<void>;
@@ -143,25 +400,12 @@ declare class KeyvCacheableMemory implements KeyvStoreAdapter {
143
400
  clear(): Promise<void>;
144
401
  has?(key: string): Promise<boolean>;
145
402
  on(event: string, listener: (...arguments_: any[]) => void): this;
403
+ getStore(namespace?: string): CacheableMemory;
146
404
  }
147
405
 
148
406
  declare const shorthandToMilliseconds: (shorthand?: string | number) => number | undefined;
149
407
  declare const shorthandToTime: (shorthand?: string | number, fromDate?: Date) => number;
150
408
 
151
- type WrapOptions = {
152
- ttl?: number | string;
153
- key?: string;
154
- cache: Cacheable;
155
- };
156
- type WrapSyncOptions = {
157
- ttl?: number | string;
158
- key?: string;
159
- cache: CacheableMemory;
160
- };
161
- type AnyFunction = (...arguments_: any[]) => any;
162
- declare function wrapSync<T>(function_: AnyFunction, options: WrapSyncOptions): AnyFunction;
163
- declare function wrap<T>(function_: AnyFunction, options: WrapOptions): AnyFunction;
164
-
165
409
  declare enum CacheableHooks {
166
410
  BEFORE_SET = "BEFORE_SET",
167
411
  AFTER_SET = "AFTER_SET",
@@ -181,6 +425,7 @@ type CacheableOptions = {
181
425
  stats?: boolean;
182
426
  nonBlocking?: boolean;
183
427
  ttl?: number | string;
428
+ namespace?: string | (() => string);
184
429
  };
185
430
  declare class Cacheable extends Hookified {
186
431
  private _primary;
@@ -188,34 +433,205 @@ declare class Cacheable extends Hookified {
188
433
  private _nonBlocking;
189
434
  private _ttl?;
190
435
  private readonly _stats;
436
+ private _namespace?;
437
+ /**
438
+ * Creates a new cacheable instance
439
+ * @param {CacheableOptions} [options] The options for the cacheable instance
440
+ */
191
441
  constructor(options?: CacheableOptions);
442
+ /**
443
+ * The namespace for the cacheable instance
444
+ * @returns {string | (() => string) | undefined} The namespace for the cacheable instance
445
+ */
446
+ get namespace(): string | (() => string) | undefined;
447
+ /**
448
+ * Sets the namespace for the cacheable instance
449
+ * @param {string | (() => string) | undefined} namespace The namespace for the cacheable instance
450
+ * @returns {void}
451
+ */
452
+ set namespace(namespace: string | (() => string) | undefined);
453
+ /**
454
+ * The statistics for the cacheable instance
455
+ * @returns {CacheableStats} The statistics for the cacheable instance
456
+ */
192
457
  get stats(): CacheableStats;
458
+ /**
459
+ * The primary store for the cacheable instance
460
+ * @returns {Keyv} The primary store for the cacheable instance
461
+ */
193
462
  get primary(): Keyv;
463
+ /**
464
+ * Sets the primary store for the cacheable instance
465
+ * @param {Keyv} primary The primary store for the cacheable instance
466
+ */
194
467
  set primary(primary: Keyv);
468
+ /**
469
+ * The secondary store for the cacheable instance
470
+ * @returns {Keyv | undefined} The secondary store for the cacheable instance
471
+ */
195
472
  get secondary(): Keyv | undefined;
473
+ /**
474
+ * Sets the secondary store for the cacheable instance. If it is set to undefined then the secondary store is disabled.
475
+ * @param {Keyv | undefined} secondary The secondary store for the cacheable instance
476
+ * @returns {void}
477
+ */
196
478
  set secondary(secondary: Keyv | undefined);
479
+ /**
480
+ * Gets whether the secondary store is non-blocking mode. It is set to false by default.
481
+ * If it is set to true then the secondary store will not block the primary store.
482
+ *
483
+ * [Learn more about non-blocking mode](https://cacheable.org/docs/cacheable/#non-blocking-operations).
484
+ *
485
+ * @returns {boolean} Whether the cacheable instance is non-blocking
486
+ */
197
487
  get nonBlocking(): boolean;
488
+ /**
489
+ * Sets whether the secondary store is non-blocking mode. It is set to false by default.
490
+ * If it is set to true then the secondary store will not block the primary store.
491
+ *
492
+ * [Learn more about non-blocking mode](https://cacheable.org/docs/cacheable/#non-blocking-operations).
493
+ *
494
+ * @param {boolean} nonBlocking Whether the cacheable instance is non-blocking
495
+ * @returns {void}
496
+ */
198
497
  set nonBlocking(nonBlocking: boolean);
498
+ /**
499
+ * The time-to-live for the cacheable instance and will be used as the default value.
500
+ * can be a number in milliseconds or a human-readable format such as `1s` for 1 second or `1h` for 1 hour
501
+ * or undefined if there is no time-to-live.
502
+ *
503
+ * [Learn more about time-to-live](https://cacheable.org/docs/cacheable/#shorthand-for-time-to-live-ttl).
504
+ *
505
+ * @returns {number | string | undefined} The time-to-live for the cacheable instance in milliseconds, human-readable format or undefined
506
+ * @example
507
+ * ```typescript
508
+ * const cacheable = new Cacheable({ ttl: '1h' });
509
+ * console.log(cacheable.ttl); // 1h
510
+ * ```
511
+ */
199
512
  get ttl(): number | string | undefined;
513
+ /**
514
+ * Sets the time-to-live for the cacheable instance and will be used as the default value.
515
+ * If you set a number it is miliseconds, if you set a string it is a human-readable
516
+ * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that
517
+ * there is no time-to-live.
518
+ *
519
+ * [Learn more about time-to-live](https://cacheable.org/docs/cacheable/#shorthand-for-time-to-live-ttl).
520
+ *
521
+ * @param {number | string | undefined} ttl The time-to-live for the cacheable instance
522
+ * @example
523
+ * ```typescript
524
+ * const cacheable = new Cacheable();
525
+ * cacheable.ttl = '1h'; // Set the time-to-live to 1 hour
526
+ * ```
527
+ * or setting the time-to-live in milliseconds
528
+ * ```typescript
529
+ * const cacheable = new Cacheable();
530
+ * cacheable.ttl = 3600000; // Set the time-to-live to 1 hour
531
+ * ```
532
+ */
200
533
  set ttl(ttl: number | string | undefined);
534
+ /**
535
+ * Sets the primary store for the cacheable instance
536
+ * @param {Keyv | KeyvStoreAdapter} primary The primary store for the cacheable instance
537
+ * @returns {void}
538
+ */
201
539
  setPrimary(primary: Keyv | KeyvStoreAdapter): void;
540
+ /**
541
+ * Sets the secondary store for the cacheable instance. If it is set to undefined then the secondary store is disabled.
542
+ * @param {Keyv | KeyvStoreAdapter} secondary The secondary store for the cacheable instance
543
+ * @returns {void}
544
+ */
202
545
  setSecondary(secondary: Keyv | KeyvStoreAdapter): void;
546
+ getNameSpace(): string | undefined;
547
+ /**
548
+ * Gets the value of the key. If the key does not exist in the primary store then it will check the secondary store.
549
+ * @param {string} key The key to get the value of
550
+ * @returns {Promise<T | undefined>} The value of the key or undefined if the key does not exist
551
+ */
203
552
  get<T>(key: string): Promise<T | undefined>;
553
+ /**
554
+ * Gets the values of the keys. If the key does not exist in the primary store then it will check the secondary store.
555
+ * @param {string[]} keys The keys to get the values of
556
+ * @returns {Promise<Array<T | undefined>>} The values of the keys or undefined if the key does not exist
557
+ */
204
558
  getMany<T>(keys: string[]): Promise<Array<T | undefined>>;
559
+ /**
560
+ * Sets the value of the key. If the secondary store is set then it will also set the value in the secondary store.
561
+ * @param {string} key the key to set the value of
562
+ * @param {T} value The value to set
563
+ * @param {number | string} [ttl] set a number it is miliseconds, set a string it is a human-readable
564
+ * format such as `1s` for 1 second or `1h` for 1 hour. Setting undefined means that it will use the default time-to-live.
565
+ * @returns {boolean} Whether the value was set
566
+ */
205
567
  set<T>(key: string, value: T, ttl?: number | string): Promise<boolean>;
568
+ /**
569
+ * Sets the values of the keys. If the secondary store is set then it will also set the values in the secondary store.
570
+ * @param {CacheableItem[]} items The items to set
571
+ * @returns {boolean} Whether the values were set
572
+ */
206
573
  setMany(items: CacheableItem[]): Promise<boolean>;
574
+ /**
575
+ * Takes the value of the key and deletes the key. If the key does not exist then it will return undefined.
576
+ * @param {string} key The key to take the value of
577
+ * @returns {Promise<T | undefined>} The value of the key or undefined if the key does not exist
578
+ */
207
579
  take<T>(key: string): Promise<T | undefined>;
580
+ /**
581
+ * Takes the values of the keys and deletes the keys. If the key does not exist then it will return undefined.
582
+ * @param {string[]} keys The keys to take the values of
583
+ * @returns {Promise<Array<T | undefined>>} The values of the keys or undefined if the key does not exist
584
+ */
208
585
  takeMany<T>(keys: string[]): Promise<Array<T | undefined>>;
586
+ /**
587
+ * Checks if the key exists in the primary store. If it does not exist then it will check the secondary store.
588
+ * @param {string} key The key to check
589
+ * @returns {Promise<boolean>} Whether the key exists
590
+ */
209
591
  has(key: string): Promise<boolean>;
592
+ /**
593
+ * Checks if the keys exist in the primary store. If it does not exist then it will check the secondary store.
594
+ * @param {string[]} keys The keys to check
595
+ * @returns {Promise<boolean[]>} Whether the keys exist
596
+ */
210
597
  hasMany(keys: string[]): Promise<boolean[]>;
598
+ /**
599
+ * Deletes the key from the primary store. If the secondary store is set then it will also delete the key from the secondary store.
600
+ * @param {string} key The key to delete
601
+ * @returns {Promise<boolean>} Whether the key was deleted
602
+ */
211
603
  delete(key: string): Promise<boolean>;
604
+ /**
605
+ * Deletes the keys from the primary store. If the secondary store is set then it will also delete the keys from the secondary store.
606
+ * @param {string[]} keys The keys to delete
607
+ * @returns {Promise<boolean>} Whether the keys were deleted
608
+ */
212
609
  deleteMany(keys: string[]): Promise<boolean>;
610
+ /**
611
+ * Clears the primary store. If the secondary store is set then it will also clear the secondary store.
612
+ * @returns {Promise<void>}
613
+ */
213
614
  clear(): Promise<void>;
615
+ /**
616
+ * Disconnects the primary store. If the secondary store is set then it will also disconnect the secondary store.
617
+ * @returns {Promise<void>}
618
+ */
214
619
  disconnect(): Promise<void>;
215
- wrap<T>(function_: (...arguments_: any[]) => T, options?: {
216
- ttl?: number;
217
- key?: string;
218
- }): (...arguments_: any[]) => T;
620
+ /**
621
+ * Wraps a function with caching
622
+ *
623
+ * [Learn more about wrapping functions](https://cacheable.org/docs/cacheable/#wrap--memoization-for-sync-and-async-functions).
624
+ * @param {Function} function_ The function to wrap
625
+ * @param {WrapOptions} [options] The options for the wrap function
626
+ * @returns {Function} The wrapped function
627
+ */
628
+ wrap<T>(function_: (...arguments_: any[]) => T, options: WrapFunctionOptions): (...arguments_: any[]) => T;
629
+ /**
630
+ * Will hash an object using the specified algorithm. The default algorithm is 'sha256'.
631
+ * @param {any} object the object to hash
632
+ * @param {string} algorithm the hash algorithm to use. The default is 'sha256'
633
+ * @returns {string} the hash of the object
634
+ */
219
635
  hash(object: any, algorithm?: string): string;
220
636
  private deleteManyKeyv;
221
637
  private setManyKeyv;