cache-manager 5.5.0 → 5.5.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.
Files changed (3) hide show
  1. package/README.md +19 -19
  2. package/package.json +12 -11
  3. package/LICENSE +0 -19
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # node-cache-manager
2
- [![codecov](https://codecov.io/gh/node-cache-manager/cache-manager/branch/main/graph/badge.svg?token=ZV3G5IFigq)](https://codecov.io/gh/node-cache-manager/cache-manager)
3
- [![tests](https://github.com/node-cache-manager/cache-manager/actions/workflows/test.yml/badge.svg)](https://github.com/node-cache-manager/cache-manager/actions/workflows/test.yml)
4
- [![license](https://img.shields.io/github/license/node-cache-manager/cache-manager)](https://github.com/node-cache-manager/cache-manager/blob/main/LICENSE)
1
+ # cache-manager
2
+ [![codecov](https://codecov.io/gh/jaredwray/cache-manager/graph/badge.svg?token=lWZ9OBQ7GM)](https://codecov.io/gh/jaredwray/cache-manager)
3
+ [![tests](https://github.com/jaredwray/cache-manager/actions/workflows/test.yml/badge.svg)](https://github.com/jaredwray/cache-manager/actions/workflows/test.yml)
4
+ [![license](https://img.shields.io/github/license/jaredwray/cache-manager)](https://github.com/jaredwray/cache-manager/blob/main/LICENSE)
5
5
  [![npm](https://img.shields.io/npm/dm/cache-manager)](https://npmjs.com/package/cache-manager)
6
6
  ![npm](https://img.shields.io/npm/v/cache-manager)
7
7
 
@@ -94,8 +94,8 @@ await memoryCache.store.mdel('foo', 'foo2');
94
94
  You can use your own custom store by creating one with the same API as the built-in memory stores.
95
95
 
96
96
  - [Example Custom Store lru-cache](./src/stores/memory.ts)
97
- - [Example Custom Store redis](https://github.com/node-cache-manager/node-cache-manager-redis-yet)
98
- - [Example Custom Store ioredis](https://github.com/node-cache-manager/node-cache-manager-ioredis-yet)
97
+ - [Example Custom Store redis](https://github.com/jaredwray/cache-manager/packages/cache-manager-redis-yet)
98
+ - [Example Custom Store ioredis](https://github.com/jaredwray/cache-manager/packages/cache-manager-ioredis-yet)
99
99
 
100
100
  #### Create single cache store synchronously
101
101
 
@@ -170,10 +170,11 @@ See unit tests in [`test/multi-caching.test.ts`](./test/multi-caching.test.ts) f
170
170
 
171
171
  ### Cache Manager Options
172
172
 
173
- The `caching` and `multiCaching` functions accept an options object as the second parameter. The following options are available:
174
- * max: The maximum number of items that can be stored in the cache. If the cache is full, the least recently used item is removed.
173
+ The `caching` function accepts an options object as the second parameter. The following options are available:
175
174
  * ttl: The time to live in milliseconds. This is the maximum amount of time that an item can be in the cache before it is removed.
176
- * shouldCloneBeforeSet: If true, the value will be cloned before being set in the cache. This is set to `true` by default.
175
+ * refreshThreshold: discussed in details below.
176
+ * isCacheable: a function to determine whether the value is cacheable or not.
177
+ * onBackgroundRefreshError: a function to handle errors that occur during background refresh.
177
178
 
178
179
  ```typescript
179
180
  import { caching } from 'cache-manager';
@@ -185,6 +186,10 @@ const memoryCache = await caching('memory', {
185
186
  });
186
187
  ```
187
188
 
189
+ When creating a memory store, you also get these addition options:
190
+ * max: The maximum number of items that can be stored in the cache. If the cache is full, the least recently used item is removed.
191
+ * shouldCloneBeforeSet: If true, the value will be cloned before being set in the cache. This is set to `true` by default.
192
+
188
193
  ### Refresh cache keys in background
189
194
 
190
195
  Both the `caching` and `multicaching` modules support a mechanism to refresh expiring cache keys in background when using the `wrap` function.
@@ -219,27 +224,22 @@ When a value will be retrieved from Redis with a TTL minor than 3sec, the value
219
224
 
220
225
  ## Error Handling
221
226
 
222
- Cache Manager now does not throw errors by default. Instead, all errors are evented through the `error` event. Here is an example on how to use it:
227
+ `multiCaching` now does not throw errors by default. Instead, all errors are evented through the `error` event. Here is an example on how to use it:
223
228
 
224
229
  ```javascript
225
- const memoryCache = await caching('memory', {
226
- max: 100,
227
- ttl: 10 * 1000 /*milliseconds*/,
228
- });
229
- memoryCache.on('error', (error) => {
230
+ const multicache = await multiCaching([memoryCache, someOtherCache]);
231
+ multicache.on('error', (error) => {
230
232
  console.error('Cache error:', error);
231
233
  });
232
234
  ```
233
235
 
234
- We also have added
235
-
236
236
  ## Store Engines
237
237
 
238
238
  ### Official and updated to last version
239
239
 
240
- - [node-cache-manager-redis-yet](https://github.com/node-cache-manager/node-cache-manager-redis-yet) (uses [node_redis](https://github.com/NodeRedis/node_redis))
240
+ - [node-cache-manager-redis-yet](https://github.com/jaredwray/cache-manager/packages/cache-manager-redis-yet) (uses [node_redis](https://github.com/NodeRedis/node_redis))
241
241
 
242
- - [node-cache-manager-ioredis-yet](https://github.com/node-cache-manager/node-cache-manager-ioredis-yet) (uses [ioredis](https://github.com/luin/ioredis))
242
+ - [node-cache-manager-ioredis-yet](https://github.com/jaredwray/cache-manager/packages/cache-manager-ioredis-yet) (uses [ioredis](https://github.com/luin/ioredis))
243
243
 
244
244
  ### Third party
245
245
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cache-manager",
3
- "version": "5.5.0",
3
+ "version": "5.5.2",
4
4
  "description": "Cache module for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,14 +9,15 @@
9
9
  "dist/**/*.d.ts"
10
10
  ],
11
11
  "scripts": {
12
- "build": "rimraf dist && tsc -p tsconfig.build.json",
12
+ "build": "tsc -p tsconfig.build.json",
13
13
  "clean": "rimraf ./dist ./coverage ./node_modules ./package-lock.json ./yarn.lock ./pnpm-lock.yaml",
14
14
  "test": "xo --fix && vitest run --coverage",
15
- "prepare": "npm run build"
15
+ "test:ci": "xo && vitest run",
16
+ "prepare": "pnpm build"
16
17
  },
17
18
  "repository": {
18
19
  "type": "git",
19
- "url": "https://github.com/node-cache-manager/cache-manager.git"
20
+ "url": "https://github.com/jaredwray/cache-manager.git"
20
21
  },
21
22
  "keywords": [
22
23
  "cache",
@@ -42,20 +43,20 @@
42
43
  "dependencies": {
43
44
  "eventemitter3": "^5.0.1",
44
45
  "lodash.clonedeep": "^4.5.0",
45
- "lru-cache": "^10.2.0",
46
+ "lru-cache": "^10.2.2",
46
47
  "promise-coalesce": "^1.1.2"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@faker-js/faker": "^8.4.1",
50
51
  "@types/lodash.clonedeep": "^4.5.9",
51
- "@types/node": "^20.11.30",
52
- "@typescript-eslint/eslint-plugin": "^7.4.0",
53
- "@typescript-eslint/parser": "^7.4.0",
54
- "@vitest/coverage-v8": "^1.4.0",
52
+ "@types/node": "^20.12.7",
53
+ "@typescript-eslint/eslint-plugin": "^7.7.1",
54
+ "@typescript-eslint/parser": "^7.7.1",
55
+ "@vitest/coverage-v8": "^1.5.2",
55
56
  "eslint-config-xo-typescript": "^4.0.0",
56
57
  "rimraf": "^5.0.5",
57
- "typescript": "^5.4.3",
58
- "vitest": "^1.4.0",
58
+ "typescript": "^5.4.5",
59
+ "vitest": "^1.5.2",
59
60
  "xo": "^0.58.0"
60
61
  },
61
62
  "xo": {
package/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- MIT License
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to
5
- deal in the Software without restriction, including without limitation the
6
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
- sell copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19
- DEALINGS IN THE SOFTWARE.