Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

cacheable

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheable - npm Package Compare versions

Comparing version
1.10.1
to
1.10.2
+1
-1
package.json
{
"name": "cacheable",
"version": "1.10.1",
"version": "1.10.2",
"description": "High Performance Layer 1 / Layer 2 Caching with Keyv Storage",

@@ -5,0 +5,0 @@ "type": "module",

@@ -35,2 +35,3 @@ [<img align="center" src="https://cacheable.org/logo.svg" alt="Cacheable" />](https://github.com/jaredwray/cacheable)

* [Non-Blocking Operations](#non-blocking-operations)
* [Non-Blocking with @keyv/redis](#non-blocking-with-keyvredis)
* [CacheSync - Distributed Updates](#cachesync---distributed-updates)

@@ -260,2 +261,25 @@ * [Cacheable Options](#cacheable-options)

# Non-Blocking with @keyv/redis
`@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:
Construct your own Redis client via the `createClient()` method from `@keyv/redis` with the following options:
* Set `disableOfflineQueue` to `true`
* Set `socket.reconnectStrategy` to `false`
In the KeyvRedis options:
* Set `throwOnConnectError` to `false`
In the Cacheable options:
* Set `nonBlocking` to `true`
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:
```javascript
import { Cacheable } from 'cacheable';
import { createKeyvNonBlocking } from '@keyv/redis';
const secondary = createKeyvNonBlocking('redis://user:pass@localhost:6379');
const cache = new Cacheable({ secondary, nonBlocking: true });
```
# GetOrSet

@@ -262,0 +286,0 @@