🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@keyv/redis

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@keyv/redis - npm Package Compare versions

Comparing version
5.1.3
to
5.1.4
+55
-45
dist/index.cjs

@@ -47,5 +47,4 @@ "use strict";

var import_hookified = require("hookified");
var import_keyv = require("keyv");
var import_client2 = require("@redis/client");
var import_keyv2 = require("keyv");
// src/types.ts
var RedisErrorMessages = /* @__PURE__ */ ((RedisErrorMessages2) => {

@@ -60,2 +59,53 @@ RedisErrorMessages2["RedisClientNotConnectedThrown"] = "Redis client is not connected or has failed to connect. This is thrown because throwOnConnectError is set to true.";

};
// src/index.ts
var import_client2 = require("@redis/client");
var import_keyv2 = require("keyv");
// src/create.ts
var import_keyv = require("keyv");
function createKeyv(connect, options) {
connect ??= "redis://localhost:6379";
const adapter = new KeyvRedis(connect, options);
if (options?.namespace) {
adapter.namespace = options.namespace;
const keyv2 = new import_keyv.Keyv(adapter, {
namespace: options?.namespace,
useKeyPrefix: false
});
if (options?.throwOnConnectError) {
keyv2.throwOnErrors = true;
}
if (options?.throwOnErrors) {
keyv2.throwOnErrors = true;
}
return keyv2;
}
const keyv = new import_keyv.Keyv(adapter, { useKeyPrefix: false });
if (options?.throwOnConnectError) {
keyv.throwOnErrors = true;
}
if (options?.throwOnErrors) {
keyv.throwOnErrors = true;
}
keyv.namespace = void 0;
return keyv;
}
function createKeyvNonBlocking(connect, options) {
const keyv = createKeyv(connect, options);
const keyvStore = keyv.store;
keyvStore.throwOnConnectError = false;
keyvStore.throwOnErrors = false;
const redisClient = keyvStore.client;
if (redisClient.options) {
redisClient.options.disableOfflineQueue = true;
if (redisClient.options.socket) {
redisClient.options.socket.reconnectStrategy = false;
}
}
keyv.throwOnErrors = false;
return keyv;
}
// src/index.ts
var KeyvRedis = class extends import_hookified.Hookified {

@@ -843,44 +893,2 @@ _client = (0, import_client.createClient)();

};
function createKeyv(connect, options) {
connect ??= "redis://localhost:6379";
const adapter = new KeyvRedis(connect, options);
if (options?.namespace) {
adapter.namespace = options.namespace;
const keyv2 = new import_keyv.Keyv(adapter, {
namespace: options?.namespace,
useKeyPrefix: false
});
if (options?.throwOnConnectError) {
keyv2.throwOnErrors = true;
}
if (options?.throwOnErrors) {
keyv2.throwOnErrors = true;
}
return keyv2;
}
const keyv = new import_keyv.Keyv(adapter, { useKeyPrefix: false });
if (options?.throwOnConnectError) {
keyv.throwOnErrors = true;
}
if (options?.throwOnErrors) {
keyv.throwOnErrors = true;
}
keyv.namespace = void 0;
return keyv;
}
function createKeyvNonBlocking(connect, options) {
const keyv = createKeyv(connect, options);
const keyvStore = keyv.store;
keyvStore.throwOnConnectError = false;
keyvStore.throwOnErrors = false;
const redisClient = keyvStore.client;
if (redisClient.options) {
redisClient.options.disableOfflineQueue = true;
if (redisClient.options.socket) {
redisClient.options.socket.reconnectStrategy = false;
}
}
keyv.throwOnErrors = false;
return keyv;
}
// Annotate the CommonJS export names for ESM import in node:

@@ -897,1 +905,3 @@ 0 && (module.exports = {

});
/* v8 ignore next -- @preserve */
/* v8 ignore next 3 -- @preserve */

@@ -1,5 +0,5 @@

import { RedisClientOptions, RedisClusterOptions, RedisSentinelOptions, RedisClientType, RedisModules, RedisFunctions, RedisScripts, RespVersions, TypeMapping, RedisClusterType, RedisSentinelType } from '@redis/client';
import { RedisClientType, RedisModules, RedisFunctions, RedisScripts, RespVersions, TypeMapping, RedisClusterType, RedisSentinelType, RedisClientOptions, RedisClusterOptions, RedisSentinelOptions } from '@redis/client';
export { RedisClientOptions, RedisClientType, RedisClusterOptions, RedisClusterType, RedisSentinelType, createClient, createCluster, createSentinel } from '@redis/client';
import { Hookified } from 'hookified';
import { KeyvStoreAdapter, KeyvEntry, Keyv } from 'keyv';
import { Keyv, KeyvStoreAdapter, KeyvEntry } from 'keyv';
export { Keyv } from 'keyv';

@@ -10,2 +10,3 @@

* Namespace for the current instance.
* Defaults to `keyv`
*/

@@ -86,2 +87,12 @@ namespace?: string;

type RedisClientConnectionType = RedisConnectionClientType | RedisConnectionClusterType | RedisConnectionSentinelType;
/**
* Will create a Keyv instance with the Redis adapter. This will also set the namespace and useKeyPrefix to false.
* @param connect - How to connect to the Redis server. If string pass in the url, if object pass in the options, if RedisClient pass in the client. If nothing is passed in, it will default to 'redis://localhost:6379'.
* @param {KeyvRedisOptions} options - Options for the adapter such as namespace, keyPrefixSeparator, and clearBatchSize.
* @returns {Keyv} - Keyv instance with the Redis adapter
*/
declare function createKeyv(connect?: string | RedisClientOptions | RedisClientType, options?: KeyvRedisOptions): Keyv;
declare function createKeyvNonBlocking(connect?: string | RedisClientOptions | RedisClientType, options?: KeyvRedisOptions): Keyv;
declare class KeyvRedis<T> extends Hookified implements KeyvStoreAdapter {

@@ -336,11 +347,3 @@ private _client;

}
/**
* Will create a Keyv instance with the Redis adapter. This will also set the namespace and useKeyPrefix to false.
* @param connect - How to connect to the Redis server. If string pass in the url, if object pass in the options, if RedisClient pass in the client. If nothing is passed in, it will default to 'redis://localhost:6379'.
* @param {KeyvRedisOptions} options - Options for the adapter such as namespace, keyPrefixSeparator, and clearBatchSize.
* @returns {Keyv} - Keyv instance with the Redis adapter
*/
declare function createKeyv(connect?: string | RedisClientOptions | RedisClientType, options?: KeyvRedisOptions): Keyv;
declare function createKeyvNonBlocking(connect?: string | RedisClientOptions | RedisClientType, options?: KeyvRedisOptions): Keyv;
export { type KeyvRedisEntry, type KeyvRedisOptions, type KeyvRedisPropertyOptions, type RedisClientConnectionType, type RedisConnectionClientType, type RedisConnectionClusterType, type RedisConnectionSentinelType, RedisErrorMessages, createKeyv, createKeyvNonBlocking, KeyvRedis as default, defaultReconnectStrategy };

@@ -1,5 +0,5 @@

import { RedisClientOptions, RedisClusterOptions, RedisSentinelOptions, RedisClientType, RedisModules, RedisFunctions, RedisScripts, RespVersions, TypeMapping, RedisClusterType, RedisSentinelType } from '@redis/client';
import { RedisClientType, RedisModules, RedisFunctions, RedisScripts, RespVersions, TypeMapping, RedisClusterType, RedisSentinelType, RedisClientOptions, RedisClusterOptions, RedisSentinelOptions } from '@redis/client';
export { RedisClientOptions, RedisClientType, RedisClusterOptions, RedisClusterType, RedisSentinelType, createClient, createCluster, createSentinel } from '@redis/client';
import { Hookified } from 'hookified';
import { KeyvStoreAdapter, KeyvEntry, Keyv } from 'keyv';
import { Keyv, KeyvStoreAdapter, KeyvEntry } from 'keyv';
export { Keyv } from 'keyv';

@@ -10,2 +10,3 @@

* Namespace for the current instance.
* Defaults to `keyv`
*/

@@ -86,2 +87,12 @@ namespace?: string;

type RedisClientConnectionType = RedisConnectionClientType | RedisConnectionClusterType | RedisConnectionSentinelType;
/**
* Will create a Keyv instance with the Redis adapter. This will also set the namespace and useKeyPrefix to false.
* @param connect - How to connect to the Redis server. If string pass in the url, if object pass in the options, if RedisClient pass in the client. If nothing is passed in, it will default to 'redis://localhost:6379'.
* @param {KeyvRedisOptions} options - Options for the adapter such as namespace, keyPrefixSeparator, and clearBatchSize.
* @returns {Keyv} - Keyv instance with the Redis adapter
*/
declare function createKeyv(connect?: string | RedisClientOptions | RedisClientType, options?: KeyvRedisOptions): Keyv;
declare function createKeyvNonBlocking(connect?: string | RedisClientOptions | RedisClientType, options?: KeyvRedisOptions): Keyv;
declare class KeyvRedis<T> extends Hookified implements KeyvStoreAdapter {

@@ -336,11 +347,3 @@ private _client;

}
/**
* Will create a Keyv instance with the Redis adapter. This will also set the namespace and useKeyPrefix to false.
* @param connect - How to connect to the Redis server. If string pass in the url, if object pass in the options, if RedisClient pass in the client. If nothing is passed in, it will default to 'redis://localhost:6379'.
* @param {KeyvRedisOptions} options - Options for the adapter such as namespace, keyPrefixSeparator, and clearBatchSize.
* @returns {Keyv} - Keyv instance with the Redis adapter
*/
declare function createKeyv(connect?: string | RedisClientOptions | RedisClientType, options?: KeyvRedisOptions): Keyv;
declare function createKeyvNonBlocking(connect?: string | RedisClientOptions | RedisClientType, options?: KeyvRedisOptions): Keyv;
export { type KeyvRedisEntry, type KeyvRedisOptions, type KeyvRedisPropertyOptions, type RedisClientConnectionType, type RedisConnectionClientType, type RedisConnectionClusterType, type RedisConnectionSentinelType, RedisErrorMessages, createKeyv, createKeyvNonBlocking, KeyvRedis as default, defaultReconnectStrategy };

@@ -9,9 +9,4 @@ // src/index.ts

import { Hookified } from "hookified";
import { Keyv } from "keyv";
import {
createClient as createClient2,
createCluster as createCluster2,
createSentinel as createSentinel2
} from "@redis/client";
import { Keyv as Keyv2 } from "keyv";
// src/types.ts
var RedisErrorMessages = /* @__PURE__ */ ((RedisErrorMessages2) => {

@@ -26,2 +21,57 @@ RedisErrorMessages2["RedisClientNotConnectedThrown"] = "Redis client is not connected or has failed to connect. This is thrown because throwOnConnectError is set to true.";

};
// src/index.ts
import {
createClient as createClient2,
createCluster as createCluster2,
createSentinel as createSentinel2
} from "@redis/client";
import { Keyv as Keyv2 } from "keyv";
// src/create.ts
import { Keyv } from "keyv";
function createKeyv(connect, options) {
connect ??= "redis://localhost:6379";
const adapter = new KeyvRedis(connect, options);
if (options?.namespace) {
adapter.namespace = options.namespace;
const keyv2 = new Keyv(adapter, {
namespace: options?.namespace,
useKeyPrefix: false
});
if (options?.throwOnConnectError) {
keyv2.throwOnErrors = true;
}
if (options?.throwOnErrors) {
keyv2.throwOnErrors = true;
}
return keyv2;
}
const keyv = new Keyv(adapter, { useKeyPrefix: false });
if (options?.throwOnConnectError) {
keyv.throwOnErrors = true;
}
if (options?.throwOnErrors) {
keyv.throwOnErrors = true;
}
keyv.namespace = void 0;
return keyv;
}
function createKeyvNonBlocking(connect, options) {
const keyv = createKeyv(connect, options);
const keyvStore = keyv.store;
keyvStore.throwOnConnectError = false;
keyvStore.throwOnErrors = false;
const redisClient = keyvStore.client;
if (redisClient.options) {
redisClient.options.disableOfflineQueue = true;
if (redisClient.options.socket) {
redisClient.options.socket.reconnectStrategy = false;
}
}
keyv.throwOnErrors = false;
return keyv;
}
// src/index.ts
var KeyvRedis = class extends Hookified {

@@ -809,44 +859,2 @@ _client = createClient();

};
function createKeyv(connect, options) {
connect ??= "redis://localhost:6379";
const adapter = new KeyvRedis(connect, options);
if (options?.namespace) {
adapter.namespace = options.namespace;
const keyv2 = new Keyv(adapter, {
namespace: options?.namespace,
useKeyPrefix: false
});
if (options?.throwOnConnectError) {
keyv2.throwOnErrors = true;
}
if (options?.throwOnErrors) {
keyv2.throwOnErrors = true;
}
return keyv2;
}
const keyv = new Keyv(adapter, { useKeyPrefix: false });
if (options?.throwOnConnectError) {
keyv.throwOnErrors = true;
}
if (options?.throwOnErrors) {
keyv.throwOnErrors = true;
}
keyv.namespace = void 0;
return keyv;
}
function createKeyvNonBlocking(connect, options) {
const keyv = createKeyv(connect, options);
const keyvStore = keyv.store;
keyvStore.throwOnConnectError = false;
keyvStore.throwOnErrors = false;
const redisClient = keyvStore.client;
if (redisClient.options) {
redisClient.options.disableOfflineQueue = true;
if (redisClient.options.socket) {
redisClient.options.socket.reconnectStrategy = false;
}
}
keyv.throwOnErrors = false;
return keyv;
}
export {

@@ -863,1 +871,3 @@ Keyv2 as Keyv,

};
/* v8 ignore next -- @preserve */
/* v8 ignore next 3 -- @preserve */
{
"name": "@keyv/redis",
"version": "5.1.3",
"version": "5.1.4",
"description": "Redis storage adapter for Keyv",

@@ -37,18 +37,18 @@ "type": "module",

"dependencies": {
"@redis/client": "^5.8.3",
"@redis/client": "^5.9.0",
"cluster-key-slot": "^1.1.2",
"hookified": "^1.12.1"
"hookified": "^1.12.2"
},
"peerDependencies": {
"keyv": "^5.5.3"
"keyv": "^5.5.4"
},
"devDependencies": {
"@biomejs/biome": "^2.2.5",
"@faker-js/faker": "^10.0.0",
"@vitest/coverage-v8": "^3.2.4",
"rimraf": "^6.0.1",
"@biomejs/biome": "^2.3.4",
"@faker-js/faker": "^10.1.0",
"@vitest/coverage-v8": "^4.0.8",
"rimraf": "^6.1.0",
"timekeeper": "^2.3.1",
"tsd": "^0.33.0",
"vitest": "^3.2.4",
"@keyv/test-suite": "^2.1.1"
"vitest": "^4.0.8",
"@keyv/test-suite": "^2.1.2"
},

@@ -55,0 +55,0 @@ "tsd": {