@cacheable/node-cache 1.5.7 → 1.5.8
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 +15 -5
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -77,14 +77,24 @@ Create a new cache instance. You can pass in options to set the configuration:
|
|
|
77
77
|
|
|
78
78
|
```javascript
|
|
79
79
|
export type NodeCacheOptions = {
|
|
80
|
-
stdTTL?: number;
|
|
81
|
-
checkperiod?: number;
|
|
82
|
-
useClones?: boolean;
|
|
83
|
-
deleteOnExpire?: boolean;
|
|
84
|
-
maxKeys?: number;
|
|
80
|
+
stdTTL?: number;
|
|
81
|
+
checkperiod?: number;
|
|
82
|
+
useClones?: boolean;
|
|
83
|
+
deleteOnExpire?: boolean;
|
|
84
|
+
maxKeys?: number;
|
|
85
85
|
};
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
Here is a description of the options:
|
|
89
|
+
|
|
90
|
+
| Option | Default Setting | Description |
|
|
91
|
+
|--------|----------------|-------------|
|
|
92
|
+
| `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. |
|
|
93
|
+
| `checkperiod` | `600` | The interval in seconds to check for expired keys. If set to `0`, it means no periodic check will be performed. |
|
|
94
|
+
| `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. |
|
|
95
|
+
| `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. |
|
|
96
|
+
| `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. |
|
|
97
|
+
|
|
88
98
|
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
99
|
|
|
90
100
|
```javascript
|
package/dist/index.d.cts
CHANGED
|
@@ -154,7 +154,12 @@ type NodeCacheOptions = {
|
|
|
154
154
|
*/
|
|
155
155
|
checkperiod?: number;
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
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
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -154,7 +154,12 @@ type NodeCacheOptions = {
|
|
|
154
154
|
*/
|
|
155
155
|
checkperiod?: number;
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
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
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cacheable/node-cache",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.8",
|
|
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": "^
|
|
36
|
-
"@vitest/coverage-v8": "^3.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.
|
|
41
|
-
"xo": "^1.1.
|
|
40
|
+
"vitest": "^3.2.4",
|
|
41
|
+
"xo": "^1.1.1"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"hookified": "^1.
|
|
45
|
-
"keyv": "^5.3.
|
|
46
|
-
"cacheable": "^1.10.
|
|
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
|
}
|