cacheable 1.10.1 → 1.10.3

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 (2) hide show
  1. package/README.md +25 -1
  2. package/package.json +7 -7
package/README.md CHANGED
@@ -32,6 +32,7 @@
32
32
  * [TTL Propagation and Storage Tiering](#ttl-propagation-and-storage-tiering)
33
33
  * [Shorthand for Time to Live (ttl)](#shorthand-for-time-to-live-ttl)
34
34
  * [Non-Blocking Operations](#non-blocking-operations)
35
+ * [Non-Blocking with @keyv/redis](#non-blocking-with-keyvredis)
35
36
  * [CacheSync - Distributed Updates](#cachesync---distributed-updates)
36
37
  * [Cacheable Options](#cacheable-options)
37
38
  * [Cacheable Statistics (Instance Only)](#cacheable-statistics-instance-only)
@@ -50,7 +51,7 @@
50
51
 
51
52
  # Getting Started
52
53
 
53
- `cacheable` is primarily used as an extension to you caching engine with a robust storage backend [Keyv](https://keyv.org), Memonization (Wrap), Hooks, Events, and Statistics.
54
+ `cacheable` is primarily used as an extension to your caching engine with a robust storage backend [Keyv](https://keyv.org), Memoization (Wrap), Hooks, Events, and Statistics.
54
55
 
55
56
  ```bash
56
57
  npm install cacheable
@@ -256,6 +257,29 @@ raws.forEach((entry, idx) => {
256
257
 
257
258
  If you want your layer 2 (secondary) store to be non-blocking you can set the `nonBlocking` property to `true` in the options. This will make the secondary store non-blocking and will not wait for the secondary store to respond on `setting data`, `deleting data`, or `clearing data`. This is useful if you want to have a faster response time and not wait for the secondary store to respond.
258
259
 
260
+ # Non-Blocking with @keyv/redis
261
+
262
+ `@keyv/redis` is one of the most popular storage adapters used with `cacheable`. It provides a Redis-backed cache store that can be used as a secondary store. It is a bit complicated to setup as by default it causes hangs and blocking with its default configuration. To get past this you will need to configure the following:
263
+
264
+ Construct your own Redis client via the `createClient()` method from `@keyv/redis` with the following options:
265
+ * Set `disableOfflineQueue` to `true`
266
+ * Set `socket.reconnectStrategy` to `false`
267
+ In the KeyvRedis options:
268
+ * Set `throwOnConnectError` to `false`
269
+ In the Cacheable options:
270
+ * Set `nonBlocking` to `true`
271
+
272
+ We have also build a function to help with this called `createKeyvNonBlocking` inside the `@keyv/redis` package after version `4.6.0`. Here is an example of how to use it:
273
+
274
+ ```javascript
275
+ import { Cacheable } from 'cacheable';
276
+ import { createKeyvNonBlocking } from '@keyv/redis';
277
+
278
+ const secondary = createKeyvNonBlocking('redis://user:pass@localhost:6379');
279
+
280
+ const cache = new Cacheable({ secondary, nonBlocking: true });
281
+ ```
282
+
259
283
  # GetOrSet
260
284
 
261
285
  The `getOrSet` method provides a convenient way to implement the cache-aside pattern. It attempts to retrieve a value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cacheable",
3
- "version": "1.10.1",
3
+ "version": "1.10.3",
4
4
  "description": "High Performance Layer 1 / Layer 2 Caching with Keyv Storage",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -21,22 +21,22 @@
21
21
  "license": "MIT",
22
22
  "private": false,
23
23
  "devDependencies": {
24
- "@faker-js/faker": "^9.8.0",
25
- "@keyv/redis": "^4.5.0",
26
- "@keyv/valkey": "^1.0.6",
24
+ "@faker-js/faker": "^9.9.0",
25
+ "@keyv/redis": "^5.0.0",
26
+ "@keyv/valkey": "^1.0.7",
27
27
  "@types/eslint": "^9.6.1",
28
- "@types/node": "^24.0.7",
28
+ "@types/node": "^24.1.0",
29
29
  "@vitest/coverage-v8": "^3.2.4",
30
30
  "lru-cache": "^11.1.0",
31
31
  "rimraf": "^6.0.1",
32
32
  "tsup": "^8.5.0",
33
33
  "typescript": "^5.8.3",
34
34
  "vitest": "^3.2.4",
35
- "xo": "^1.1.1"
35
+ "xo": "^1.2.1"
36
36
  },
37
37
  "dependencies": {
38
38
  "hookified": "^1.10.0",
39
- "keyv": "^5.3.4"
39
+ "keyv": "^5.4.0"
40
40
  },
41
41
  "keywords": [
42
42
  "cacheable",