@cacheable/node-cache 1.5.7 → 1.6.0

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/README.md CHANGED
@@ -60,6 +60,16 @@ cache.set('foo', 'bar');
60
60
  cache.get('foo'); // 'bar'
61
61
  ```
62
62
 
63
+ `NodeCache` also offers the ability to set the type of values that can be cached in Typescript environments.
64
+
65
+ ```typescript
66
+ import {NodeCache} from '@cacheable/node-cache';
67
+
68
+ const cache = new NodeCache<string>();
69
+ cache.set('foo', 'bar');
70
+ cache.get('foo'); // 'bar'
71
+ ```
72
+
63
73
  # NodeCache Performance
64
74
 
65
75
  The performance is comparable if not faster to the original `node-cache` package, but with additional features and improvements.
@@ -77,14 +87,24 @@ Create a new cache instance. You can pass in options to set the configuration:
77
87
 
78
88
  ```javascript
79
89
  export type NodeCacheOptions = {
80
- stdTTL?: number; // The standard ttl as number in seconds for every generated cache element. 0 = unlimited. If string, it will be parsed as shorthand and default to milliseconds if it is a number as a string.
81
- checkperiod?: number; // Default is 600, 0 means no periodic check
82
- useClones?: boolean; // Default is true
83
- deleteOnExpire?: boolean; // Default is true, if false it will keep the key and not delete during an interval check and the value on get() will be undefined
84
- maxKeys?: number; // Default is -1 (unlimited). If this is set it will throw and error if you try to set more keys than the max.
90
+ stdTTL?: number;
91
+ checkperiod?: number;
92
+ useClones?: boolean;
93
+ deleteOnExpire?: boolean;
94
+ maxKeys?: number;
85
95
  };
86
96
  ```
87
97
 
98
+ Here is a description of the options:
99
+
100
+ | Option | Default Setting | Description |
101
+ |--------|----------------|-------------|
102
+ | `stdTTL` | `0` | The standard time to live (TTL) in seconds for every generated cache element. If set to `0`, it means unlimited. If a string is provided, it will be parsed as shorthand and default to milliseconds if it is a number as a string. |
103
+ | `checkperiod` | `600` | The interval in seconds to check for expired keys. If set to `0`, it means no periodic check will be performed. |
104
+ | `useClones` | `true` | If set to `true`, the cache will clone the returned items via `get()` functions. This means that every time you set a value into the cache, `node-cache` makes a deep clone of it. When you get that value back, you receive another deep clone. This mimics the behavior of an external cache like Redis or Memcached, meaning mutations to the returned object do not affect the cached copy (and vice versa). If set to `false`, the original object will be returned, and mutations will affect the cached copy. |
105
+ | `deleteOnExpire` | `true` | If set to `true`, the key will be deleted when it expires. If set to `false`, the key will remain in the cache, but the value returned by `get()` will be `undefined`. You can manage the key with the `on('expired')` event. |
106
+ | `maxKeys` | `-1` | If set to a positive number, it will limit the number of keys in the cache. If the number of keys exceeds this limit, it will throw an error when trying to set more keys than the maximum. If set to `-1`, it means unlimited keys are allowed. |
107
+
88
108
  When initializing the cache you can pass in the options to set the configuration like the example below where we set the `stdTTL` to 10 seconds and `checkperiod` to 5 seconds.:
89
109
 
90
110
  ```javascript
package/dist/index.cjs CHANGED
@@ -79,7 +79,7 @@ var NodeCacheStore = class extends import_hookified.Hookified {
79
79
  }
80
80
  /**
81
81
  * Primary cache store.
82
- * @returns {Keyv}
82
+ * @returns {Keyv<T>}
83
83
  * @readonly
84
84
  */
85
85
  get primary() {
@@ -87,7 +87,7 @@ var NodeCacheStore = class extends import_hookified.Hookified {
87
87
  }
88
88
  /**
89
89
  * Primary cache store.
90
- * @param {Keyv} primary
90
+ * @param {Keyv<T>} primary
91
91
  */
92
92
  set primary(primary) {
93
93
  this._cache.primary = primary;
@@ -95,7 +95,7 @@ var NodeCacheStore = class extends import_hookified.Hookified {
95
95
  /**
96
96
  * Secondary cache store. Learn more about the secondary cache store in the
97
97
  * [cacheable](https://github.com/jaredwray/cacheable/tree/main/packages/cacheable#storage-tiering-and-caching) documentation.
98
- * @returns {Keyv | undefined}
98
+ * @returns {Keyv<T> | undefined}
99
99
  */
100
100
  get secondary() {
101
101
  return this._cache.secondary;
@@ -131,7 +131,7 @@ var NodeCacheStore = class extends import_hookified.Hookified {
131
131
  /**
132
132
  * Set a key/value pair in the cache.
133
133
  * @param {string | number} key
134
- * @param {any} value
134
+ * @param {T} value
135
135
  * @param {number} [ttl]
136
136
  * @returns {boolean}
137
137
  */
@@ -146,7 +146,7 @@ var NodeCacheStore = class extends import_hookified.Hookified {
146
146
  }
147
147
  /**
148
148
  * Set multiple key/value pairs in the cache.
149
- * @param {NodeCacheItem[]} list
149
+ * @param {PartialNodeCacheItem[]} list
150
150
  * @returns {void}
151
151
  */
152
152
  async mset(list) {
@@ -260,11 +260,11 @@ var NodeCache = class extends import_hookified2.Hookified {
260
260
  /**
261
261
  * Sets a key value pair. It is possible to define a ttl (in seconds). Returns true on success.
262
262
  * @param {string | number} key - it will convert the key to a string
263
- * @param {any} value
263
+ * @param {T} value
264
264
  * @param {number | string} [ttl] - this is in seconds and undefined will use the default ttl
265
265
  * @returns {boolean}
266
266
  */
267
- set(key, value, ttl) {
267
+ set(key, value, ttl = 0) {
268
268
  if (typeof key !== "string" && typeof key !== "number") {
269
269
  throw this.createError("The key argument has to be of type `string` or `number`. Found: `__key`" /* EKEYTYPE */, key);
270
270
  }
@@ -298,7 +298,7 @@ var NodeCache = class extends import_hookified2.Hookified {
298
298
  }
299
299
  /**
300
300
  * Sets multiple key val pairs. It is possible to define a ttl (seconds). Returns true on success.
301
- * @param {NodeCacheItem[]} data an array of key value pairs with optional ttl
301
+ * @param {PartialNodeCacheItem<T>[]} data an array of key value pairs with optional ttl
302
302
  * @returns {boolean}
303
303
  */
304
304
  mset(data) {
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { Hookified } from 'hookified';
2
2
  import { Cacheable } from 'cacheable';
3
3
  import { Keyv } from 'keyv';
4
4
 
5
- type NodeCacheStoreOptions = {
5
+ type NodeCacheStoreOptions<T> = {
6
6
  /**
7
7
  * Time to live in milliseconds. This is a breaking change from the original NodeCache.
8
8
  */
@@ -14,21 +14,21 @@ type NodeCacheStoreOptions = {
14
14
  /**
15
15
  * Primary cache store.
16
16
  */
17
- primary?: Keyv;
17
+ primary?: Keyv<T>;
18
18
  /**
19
19
  * Secondary cache store. Learn more about the secondary cache store in the cacheable documentation.
20
20
  * [storage-tiering-and-caching](https://github.com/jaredwray/cacheable/tree/main/packages/cacheable#storage-tiering-and-caching)
21
21
  */
22
- secondary?: Keyv;
22
+ secondary?: Keyv<T>;
23
23
  /**
24
24
  * Enable stats tracking. This is a breaking change from the original NodeCache.
25
25
  */
26
26
  stats?: boolean;
27
27
  };
28
- declare class NodeCacheStore extends Hookified {
28
+ declare class NodeCacheStore<T> extends Hookified {
29
29
  private _maxKeys;
30
30
  private readonly _cache;
31
- constructor(options?: NodeCacheStoreOptions);
31
+ constructor(options?: NodeCacheStoreOptions<T>);
32
32
  /**
33
33
  * Cacheable instance.
34
34
  * @returns {Cacheable}
@@ -48,21 +48,21 @@ declare class NodeCacheStore extends Hookified {
48
48
  set ttl(ttl: number | string | undefined);
49
49
  /**
50
50
  * Primary cache store.
51
- * @returns {Keyv}
51
+ * @returns {Keyv<T>}
52
52
  * @readonly
53
53
  */
54
- get primary(): Keyv;
54
+ get primary(): Keyv<T>;
55
55
  /**
56
56
  * Primary cache store.
57
- * @param {Keyv} primary
57
+ * @param {Keyv<T>} primary
58
58
  */
59
- set primary(primary: Keyv);
59
+ set primary(primary: Keyv<T>);
60
60
  /**
61
61
  * Secondary cache store. Learn more about the secondary cache store in the
62
62
  * [cacheable](https://github.com/jaredwray/cacheable/tree/main/packages/cacheable#storage-tiering-and-caching) documentation.
63
- * @returns {Keyv | undefined}
63
+ * @returns {Keyv<T> | undefined}
64
64
  */
65
- get secondary(): Keyv | undefined;
65
+ get secondary(): Keyv<T> | undefined;
66
66
  /**
67
67
  * Secondary cache store. Learn more about the secondary cache store in the
68
68
  * [cacheable](https://github.com/jaredwray/cacheable/tree/main/packages/cacheable#storage-tiering-and-caching) documentation.
@@ -85,17 +85,17 @@ declare class NodeCacheStore extends Hookified {
85
85
  /**
86
86
  * Set a key/value pair in the cache.
87
87
  * @param {string | number} key
88
- * @param {any} value
88
+ * @param {T} value
89
89
  * @param {number} [ttl]
90
90
  * @returns {boolean}
91
91
  */
92
- set(key: string | number, value: any, ttl?: number): Promise<boolean>;
92
+ set(key: string | number, value: T, ttl?: number): Promise<boolean>;
93
93
  /**
94
94
  * Set multiple key/value pairs in the cache.
95
- * @param {NodeCacheItem[]} list
95
+ * @param {PartialNodeCacheItem[]} list
96
96
  * @returns {void}
97
97
  */
98
- mset(list: NodeCacheItem[]): Promise<void>;
98
+ mset(list: Array<PartialNodeCacheItem<T>>): Promise<void>;
99
99
  /**
100
100
  * Get a value from the cache.
101
101
  * @param {string | number} key
@@ -154,7 +154,12 @@ type NodeCacheOptions = {
154
154
  */
155
155
  checkperiod?: number;
156
156
  /**
157
- * Clones the returned items via get functions. Default is true.
157
+ * If set to true (Default Setting), the cache will clone the returned items via get() functions.
158
+ * This means that every time you set a value into the cache, node-cache makes a deep clone of it.
159
+ * When you get that value back, you receive another deep clone.
160
+ * This mimics the behavior of an external cache like Redis or Memcached, meaning mutations to the
161
+ * returned object do not affect the cached copy (and vice versa). If set to false, the original
162
+ * object will be returned, and mutations will affect the cached copy.
158
163
  */
159
164
  useClones?: boolean;
160
165
  /**
@@ -167,7 +172,7 @@ type NodeCacheOptions = {
167
172
  */
168
173
  maxKeys?: number;
169
174
  };
170
- type NodeCacheItem = {
175
+ type PartialNodeCacheItem<T> = {
171
176
  /**
172
177
  * The key of the item
173
178
  */
@@ -175,12 +180,18 @@ type NodeCacheItem = {
175
180
  /**
176
181
  * The value of the item
177
182
  */
178
- value: unknown;
183
+ value: T;
179
184
  /**
180
185
  * The ttl of the item in seconds. 0 = unlimited
181
186
  */
182
187
  ttl?: number;
183
188
  };
189
+ type NodeCacheItem<T> = PartialNodeCacheItem<T> & {
190
+ /**
191
+ * The ttl of the item in milliseconds. 0 = unlimited
192
+ */
193
+ ttl: number;
194
+ };
184
195
  declare enum NodeCacheErrors {
185
196
  ECACHEFULL = "Cache max keys amount exceeded",
186
197
  EKEYTYPE = "The key argument has to be of type `string` or `number`. Found: `__key`",
@@ -209,9 +220,9 @@ type NodeCacheStats = {
209
220
  */
210
221
  vsize: number;
211
222
  };
212
- declare class NodeCache extends Hookified {
223
+ declare class NodeCache<T> extends Hookified {
213
224
  readonly options: NodeCacheOptions;
214
- readonly store: Map<string, any>;
225
+ readonly store: Map<string, NodeCacheItem<T>>;
215
226
  private _stats;
216
227
  private readonly _cacheable;
217
228
  private intervalId;
@@ -219,23 +230,23 @@ declare class NodeCache extends Hookified {
219
230
  /**
220
231
  * Sets a key value pair. It is possible to define a ttl (in seconds). Returns true on success.
221
232
  * @param {string | number} key - it will convert the key to a string
222
- * @param {any} value
233
+ * @param {T} value
223
234
  * @param {number | string} [ttl] - this is in seconds and undefined will use the default ttl
224
235
  * @returns {boolean}
225
236
  */
226
- set(key: string | number, value: any, ttl?: number | string): boolean;
237
+ set(key: string | number, value: T, ttl?: number | string): boolean;
227
238
  /**
228
239
  * Sets multiple key val pairs. It is possible to define a ttl (seconds). Returns true on success.
229
- * @param {NodeCacheItem[]} data an array of key value pairs with optional ttl
240
+ * @param {PartialNodeCacheItem<T>[]} data an array of key value pairs with optional ttl
230
241
  * @returns {boolean}
231
242
  */
232
- mset(data: NodeCacheItem[]): boolean;
243
+ mset(data: Array<PartialNodeCacheItem<T>>): boolean;
233
244
  /**
234
245
  * Gets a saved value from the cache. Returns a undefined if not found or expired. If the value was found it returns the value.
235
246
  * @param {string | number} key if the key is a number it will convert it to a string
236
247
  * @returns {T} the value or undefined
237
248
  */
238
- get<T>(key: string | number): T | undefined;
249
+ get(key: string | number): T | undefined;
239
250
  /**
240
251
  * Gets multiple saved values from the cache. Returns an empty object {} if not found or expired.
241
252
  * If the value was found it returns an object with the key value pair.
@@ -321,4 +332,4 @@ declare class NodeCache extends Hookified {
321
332
  private createError;
322
333
  }
323
334
 
324
- export { NodeCache, NodeCacheErrors, type NodeCacheItem, type NodeCacheOptions, type NodeCacheStats, NodeCacheStore, type NodeCacheStoreOptions, NodeCache as default };
335
+ export { NodeCache, NodeCacheErrors, type NodeCacheItem, type NodeCacheOptions, type NodeCacheStats, NodeCacheStore, type NodeCacheStoreOptions, type PartialNodeCacheItem, NodeCache as default };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { Hookified } from 'hookified';
2
2
  import { Cacheable } from 'cacheable';
3
3
  import { Keyv } from 'keyv';
4
4
 
5
- type NodeCacheStoreOptions = {
5
+ type NodeCacheStoreOptions<T> = {
6
6
  /**
7
7
  * Time to live in milliseconds. This is a breaking change from the original NodeCache.
8
8
  */
@@ -14,21 +14,21 @@ type NodeCacheStoreOptions = {
14
14
  /**
15
15
  * Primary cache store.
16
16
  */
17
- primary?: Keyv;
17
+ primary?: Keyv<T>;
18
18
  /**
19
19
  * Secondary cache store. Learn more about the secondary cache store in the cacheable documentation.
20
20
  * [storage-tiering-and-caching](https://github.com/jaredwray/cacheable/tree/main/packages/cacheable#storage-tiering-and-caching)
21
21
  */
22
- secondary?: Keyv;
22
+ secondary?: Keyv<T>;
23
23
  /**
24
24
  * Enable stats tracking. This is a breaking change from the original NodeCache.
25
25
  */
26
26
  stats?: boolean;
27
27
  };
28
- declare class NodeCacheStore extends Hookified {
28
+ declare class NodeCacheStore<T> extends Hookified {
29
29
  private _maxKeys;
30
30
  private readonly _cache;
31
- constructor(options?: NodeCacheStoreOptions);
31
+ constructor(options?: NodeCacheStoreOptions<T>);
32
32
  /**
33
33
  * Cacheable instance.
34
34
  * @returns {Cacheable}
@@ -48,21 +48,21 @@ declare class NodeCacheStore extends Hookified {
48
48
  set ttl(ttl: number | string | undefined);
49
49
  /**
50
50
  * Primary cache store.
51
- * @returns {Keyv}
51
+ * @returns {Keyv<T>}
52
52
  * @readonly
53
53
  */
54
- get primary(): Keyv;
54
+ get primary(): Keyv<T>;
55
55
  /**
56
56
  * Primary cache store.
57
- * @param {Keyv} primary
57
+ * @param {Keyv<T>} primary
58
58
  */
59
- set primary(primary: Keyv);
59
+ set primary(primary: Keyv<T>);
60
60
  /**
61
61
  * Secondary cache store. Learn more about the secondary cache store in the
62
62
  * [cacheable](https://github.com/jaredwray/cacheable/tree/main/packages/cacheable#storage-tiering-and-caching) documentation.
63
- * @returns {Keyv | undefined}
63
+ * @returns {Keyv<T> | undefined}
64
64
  */
65
- get secondary(): Keyv | undefined;
65
+ get secondary(): Keyv<T> | undefined;
66
66
  /**
67
67
  * Secondary cache store. Learn more about the secondary cache store in the
68
68
  * [cacheable](https://github.com/jaredwray/cacheable/tree/main/packages/cacheable#storage-tiering-and-caching) documentation.
@@ -85,17 +85,17 @@ declare class NodeCacheStore extends Hookified {
85
85
  /**
86
86
  * Set a key/value pair in the cache.
87
87
  * @param {string | number} key
88
- * @param {any} value
88
+ * @param {T} value
89
89
  * @param {number} [ttl]
90
90
  * @returns {boolean}
91
91
  */
92
- set(key: string | number, value: any, ttl?: number): Promise<boolean>;
92
+ set(key: string | number, value: T, ttl?: number): Promise<boolean>;
93
93
  /**
94
94
  * Set multiple key/value pairs in the cache.
95
- * @param {NodeCacheItem[]} list
95
+ * @param {PartialNodeCacheItem[]} list
96
96
  * @returns {void}
97
97
  */
98
- mset(list: NodeCacheItem[]): Promise<void>;
98
+ mset(list: Array<PartialNodeCacheItem<T>>): Promise<void>;
99
99
  /**
100
100
  * Get a value from the cache.
101
101
  * @param {string | number} key
@@ -154,7 +154,12 @@ type NodeCacheOptions = {
154
154
  */
155
155
  checkperiod?: number;
156
156
  /**
157
- * Clones the returned items via get functions. Default is true.
157
+ * If set to true (Default Setting), the cache will clone the returned items via get() functions.
158
+ * This means that every time you set a value into the cache, node-cache makes a deep clone of it.
159
+ * When you get that value back, you receive another deep clone.
160
+ * This mimics the behavior of an external cache like Redis or Memcached, meaning mutations to the
161
+ * returned object do not affect the cached copy (and vice versa). If set to false, the original
162
+ * object will be returned, and mutations will affect the cached copy.
158
163
  */
159
164
  useClones?: boolean;
160
165
  /**
@@ -167,7 +172,7 @@ type NodeCacheOptions = {
167
172
  */
168
173
  maxKeys?: number;
169
174
  };
170
- type NodeCacheItem = {
175
+ type PartialNodeCacheItem<T> = {
171
176
  /**
172
177
  * The key of the item
173
178
  */
@@ -175,12 +180,18 @@ type NodeCacheItem = {
175
180
  /**
176
181
  * The value of the item
177
182
  */
178
- value: unknown;
183
+ value: T;
179
184
  /**
180
185
  * The ttl of the item in seconds. 0 = unlimited
181
186
  */
182
187
  ttl?: number;
183
188
  };
189
+ type NodeCacheItem<T> = PartialNodeCacheItem<T> & {
190
+ /**
191
+ * The ttl of the item in milliseconds. 0 = unlimited
192
+ */
193
+ ttl: number;
194
+ };
184
195
  declare enum NodeCacheErrors {
185
196
  ECACHEFULL = "Cache max keys amount exceeded",
186
197
  EKEYTYPE = "The key argument has to be of type `string` or `number`. Found: `__key`",
@@ -209,9 +220,9 @@ type NodeCacheStats = {
209
220
  */
210
221
  vsize: number;
211
222
  };
212
- declare class NodeCache extends Hookified {
223
+ declare class NodeCache<T> extends Hookified {
213
224
  readonly options: NodeCacheOptions;
214
- readonly store: Map<string, any>;
225
+ readonly store: Map<string, NodeCacheItem<T>>;
215
226
  private _stats;
216
227
  private readonly _cacheable;
217
228
  private intervalId;
@@ -219,23 +230,23 @@ declare class NodeCache extends Hookified {
219
230
  /**
220
231
  * Sets a key value pair. It is possible to define a ttl (in seconds). Returns true on success.
221
232
  * @param {string | number} key - it will convert the key to a string
222
- * @param {any} value
233
+ * @param {T} value
223
234
  * @param {number | string} [ttl] - this is in seconds and undefined will use the default ttl
224
235
  * @returns {boolean}
225
236
  */
226
- set(key: string | number, value: any, ttl?: number | string): boolean;
237
+ set(key: string | number, value: T, ttl?: number | string): boolean;
227
238
  /**
228
239
  * Sets multiple key val pairs. It is possible to define a ttl (seconds). Returns true on success.
229
- * @param {NodeCacheItem[]} data an array of key value pairs with optional ttl
240
+ * @param {PartialNodeCacheItem<T>[]} data an array of key value pairs with optional ttl
230
241
  * @returns {boolean}
231
242
  */
232
- mset(data: NodeCacheItem[]): boolean;
243
+ mset(data: Array<PartialNodeCacheItem<T>>): boolean;
233
244
  /**
234
245
  * Gets a saved value from the cache. Returns a undefined if not found or expired. If the value was found it returns the value.
235
246
  * @param {string | number} key if the key is a number it will convert it to a string
236
247
  * @returns {T} the value or undefined
237
248
  */
238
- get<T>(key: string | number): T | undefined;
249
+ get(key: string | number): T | undefined;
239
250
  /**
240
251
  * Gets multiple saved values from the cache. Returns an empty object {} if not found or expired.
241
252
  * If the value was found it returns an object with the key value pair.
@@ -321,4 +332,4 @@ declare class NodeCache extends Hookified {
321
332
  private createError;
322
333
  }
323
334
 
324
- export { NodeCache, NodeCacheErrors, type NodeCacheItem, type NodeCacheOptions, type NodeCacheStats, NodeCacheStore, type NodeCacheStoreOptions, NodeCache as default };
335
+ export { NodeCache, NodeCacheErrors, type NodeCacheItem, type NodeCacheOptions, type NodeCacheStats, NodeCacheStore, type NodeCacheStoreOptions, type PartialNodeCacheItem, NodeCache as default };
package/dist/index.js CHANGED
@@ -52,7 +52,7 @@ var NodeCacheStore = class extends Hookified {
52
52
  }
53
53
  /**
54
54
  * Primary cache store.
55
- * @returns {Keyv}
55
+ * @returns {Keyv<T>}
56
56
  * @readonly
57
57
  */
58
58
  get primary() {
@@ -60,7 +60,7 @@ var NodeCacheStore = class extends Hookified {
60
60
  }
61
61
  /**
62
62
  * Primary cache store.
63
- * @param {Keyv} primary
63
+ * @param {Keyv<T>} primary
64
64
  */
65
65
  set primary(primary) {
66
66
  this._cache.primary = primary;
@@ -68,7 +68,7 @@ var NodeCacheStore = class extends Hookified {
68
68
  /**
69
69
  * Secondary cache store. Learn more about the secondary cache store in the
70
70
  * [cacheable](https://github.com/jaredwray/cacheable/tree/main/packages/cacheable#storage-tiering-and-caching) documentation.
71
- * @returns {Keyv | undefined}
71
+ * @returns {Keyv<T> | undefined}
72
72
  */
73
73
  get secondary() {
74
74
  return this._cache.secondary;
@@ -104,7 +104,7 @@ var NodeCacheStore = class extends Hookified {
104
104
  /**
105
105
  * Set a key/value pair in the cache.
106
106
  * @param {string | number} key
107
- * @param {any} value
107
+ * @param {T} value
108
108
  * @param {number} [ttl]
109
109
  * @returns {boolean}
110
110
  */
@@ -119,7 +119,7 @@ var NodeCacheStore = class extends Hookified {
119
119
  }
120
120
  /**
121
121
  * Set multiple key/value pairs in the cache.
122
- * @param {NodeCacheItem[]} list
122
+ * @param {PartialNodeCacheItem[]} list
123
123
  * @returns {void}
124
124
  */
125
125
  async mset(list) {
@@ -233,11 +233,11 @@ var NodeCache = class extends Hookified2 {
233
233
  /**
234
234
  * Sets a key value pair. It is possible to define a ttl (in seconds). Returns true on success.
235
235
  * @param {string | number} key - it will convert the key to a string
236
- * @param {any} value
236
+ * @param {T} value
237
237
  * @param {number | string} [ttl] - this is in seconds and undefined will use the default ttl
238
238
  * @returns {boolean}
239
239
  */
240
- set(key, value, ttl) {
240
+ set(key, value, ttl = 0) {
241
241
  if (typeof key !== "string" && typeof key !== "number") {
242
242
  throw this.createError("The key argument has to be of type `string` or `number`. Found: `__key`" /* EKEYTYPE */, key);
243
243
  }
@@ -271,7 +271,7 @@ var NodeCache = class extends Hookified2 {
271
271
  }
272
272
  /**
273
273
  * Sets multiple key val pairs. It is possible to define a ttl (seconds). Returns true on success.
274
- * @param {NodeCacheItem[]} data an array of key value pairs with optional ttl
274
+ * @param {PartialNodeCacheItem<T>[]} data an array of key value pairs with optional ttl
275
275
  * @returns {boolean}
276
276
  */
277
277
  mset(data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cacheable/node-cache",
3
- "version": "1.5.7",
3
+ "version": "1.6.0",
4
4
  "description": "Simple and Maintained fast NodeJS internal caching",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -32,18 +32,18 @@
32
32
  ],
33
33
  "devDependencies": {
34
34
  "@types/eslint": "^9.6.1",
35
- "@types/node": "^22.15.30",
36
- "@vitest/coverage-v8": "^3.2.2",
35
+ "@types/node": "^24.0.7",
36
+ "@vitest/coverage-v8": "^3.2.4",
37
37
  "rimraf": "^6.0.1",
38
38
  "tsup": "^8.5.0",
39
39
  "typescript": "^5.8.3",
40
- "vitest": "^3.2.2",
41
- "xo": "^1.1.0"
40
+ "vitest": "^3.2.4",
41
+ "xo": "^1.1.1"
42
42
  },
43
43
  "dependencies": {
44
- "hookified": "^1.9.1",
45
- "keyv": "^5.3.3",
46
- "cacheable": "^1.10.0"
44
+ "hookified": "^1.10.0",
45
+ "keyv": "^5.3.4",
46
+ "cacheable": "^1.10.1"
47
47
  },
48
48
  "files": [
49
49
  "dist",
@@ -53,7 +53,7 @@
53
53
  "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
54
54
  "prepublish": "pnpm build",
55
55
  "test": "xo --fix && vitest run --coverage",
56
- "test:ci": "xo && vitest run",
56
+ "test:ci": "xo && vitest run --coverage",
57
57
  "clean": "rimraf ./dist ./coverage ./node_modules"
58
58
  }
59
59
  }