@keyv/redis 2.3.6 → 2.3.9

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 CHANGED
@@ -3,8 +3,9 @@
3
3
  > Redis storage adapter for Keyv
4
4
 
5
5
  [![build](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml/badge.svg)](https://github.com/jaredwray/keyv/actions/workflows/tests.yaml)
6
- [![codecov](https://codecov.io/gh/jaredwray/keyv/branch/master/graph/badge.svg?token=bRzR3RyOXZ)](https://codecov.io/gh/jaredwray/keyv)
6
+ [![codecov](https://codecov.io/gh/jaredwray/keyv/branch/main/graph/badge.svg?token=bRzR3RyOXZ)](https://codecov.io/gh/jaredwray/keyv)
7
7
  [![npm](https://img.shields.io/npm/v/@keyv/redis.svg)](https://www.npmjs.com/package/@keyv/redis)
8
+ [![npm](https://img.shields.io/npm/dm/@keyv/redis)](https://npmjs.com/package/@keyv/redis)
8
9
 
9
10
  Redis storage adapter for [Keyv](https://github.com/jaredwray/keyv).
10
11
 
@@ -55,6 +56,18 @@ const keyvRedis = new KeyvRedis(redis);
55
56
  const keyv = new Keyv({ store: keyvRedis });
56
57
  ```
57
58
 
59
+ Or reuse a previous Redis cluster:
60
+
61
+ ```js
62
+ const KeyvRedis = require('@keyv/redis');
63
+ const Redis = require('ioredis');
64
+ const Keyv = require('keyv');
65
+
66
+ const redis = new Redis.Cluster('redis://user:pass@localhost:6379');
67
+ const keyvRedis = new KeyvRedis(redis);
68
+ const keyv = new Keyv({ store: keyvRedis });
69
+ ```
70
+
58
71
  ## License
59
72
 
60
- MIT © Jared Wray & Luke Childs
73
+ MIT © Jared Wray
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyv/redis",
3
- "version": "2.3.6",
3
+ "version": "2.3.9",
4
4
  "description": "Redis storage adapter for Keyv",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -11,12 +11,26 @@
11
11
  "xo": {
12
12
  "rules": {
13
13
  "unicorn/prefer-module": 0,
14
- "unicorn/prefer-node-protocol": 0
14
+ "unicorn/prefer-node-protocol": 0,
15
+ "ava/no-ignored-test-files": [
16
+ "error",
17
+ {
18
+ "extensions": [
19
+ "js",
20
+ "ts"
21
+ ]
22
+ }
23
+ ]
15
24
  }
16
25
  },
17
26
  "ava": {
18
27
  "require": [
19
- "requirable"
28
+ "requirable",
29
+ "ts-node/register"
30
+ ],
31
+ "extensions": [
32
+ "js",
33
+ "ts"
20
34
  ]
21
35
  },
22
36
  "repository": {
@@ -41,19 +55,21 @@
41
55
  },
42
56
  "homepage": "https://github.com/jaredwray/keyv",
43
57
  "dependencies": {
44
- "ioredis": "^5.0.4"
58
+ "ioredis": "^5.1.0"
45
59
  },
46
60
  "devDependencies": {
47
61
  "@keyv/test-suite": "*",
48
- "ava": "^4.2.0",
62
+ "ava": "^4.3.0",
49
63
  "delay": "^5.0.0",
64
+ "@types/keyv": "^3.1.4",
50
65
  "keyv": "*",
51
66
  "nyc": "^15.1.0",
67
+ "ts-node": "^10.8.2",
52
68
  "requirable": "^1.0.5",
53
69
  "this": "^1.1.0",
54
- "tsd": "^0.20.0",
55
- "typescript": "^4.6.4",
56
- "xo": "^0.48.0"
70
+ "tsd": "^0.22.0",
71
+ "typescript": "^4.7.4",
72
+ "xo": "^0.50.0"
57
73
  },
58
74
  "tsd": {
59
75
  "directory": "test"
package/src/index.d.ts CHANGED
@@ -1,22 +1,24 @@
1
1
  import {EventEmitter} from 'events';
2
- import {Store} from 'keyv';
2
+ import {Store, StoredData} from 'keyv';
3
3
  import {Redis, Cluster} from 'ioredis';
4
4
 
5
- declare class KeyvRedis extends EventEmitter implements Store<string | undefined> {
5
+ declare class KeyvRedis extends EventEmitter implements Store<Value> {
6
6
  readonly ttlSupport: false;
7
7
  namespace?: string | undefined;
8
8
  opts: Record<string, unknown>;
9
9
  redis: any;
10
10
  constructor(options?: KeyvRedis.Options | Redis | Cluster);
11
11
  constructor(uri: string | Redis | Cluster, options?: KeyvRedis.Options);
12
- get(key: string): Promise<string | undefined>;
13
- getMany(keys: string[]): Promise<string[] | undefined>;
14
- set(key: string, value: string | undefined, ttl?: number): Promise<any>;
15
- delete(key: string): boolean;
12
+ get(key: string): Promise<Value>;
13
+ getMany?(
14
+ keys: string[]
15
+ ): Array<StoredData<Value>> | Promise<Array<StoredData<Value>>> | undefined;
16
+ set(key: string, value: Value, ttl?: number): any;
17
+ delete(key: string): boolean | Promise<boolean>;
16
18
  deleteMany(keys: string[]): boolean;
17
- clear(): Promise<void>;
19
+ clear(): void | Promise<void>;
18
20
  iterator(namespace: string | undefined): AsyncGenerator<any, void, any>;
19
- has(key: string): boolean;
21
+ has?(key: string): boolean | Promise<boolean>;
20
22
  }
21
23
  declare namespace KeyvRedis {
22
24
  interface Options {
package/src/index.js CHANGED
@@ -8,7 +8,7 @@ class KeyvRedis extends EventEmitter {
8
8
  this.opts = {};
9
9
  this.opts.dialect = 'redis';
10
10
 
11
- if ((uri.options && uri.options.family)) {
11
+ if ((uri.options && uri.options.family) || (uri.options && uri.isCluster)) {
12
12
  this.redis = uri;
13
13
  } else {
14
14
  options = {...(typeof uri === 'string' ? {uri} : uri), ...options};
@@ -51,7 +51,9 @@ class KeyvRedis extends EventEmitter {
51
51
 
52
52
  return this.redis.set(key, value);
53
53
  })
54
- .then(() => this.redis.sadd(this._getNamespace(), key));
54
+ .then(() => {
55
+ this.redis.sadd(this._getNamespace(), key);
56
+ });
55
57
  }
56
58
 
57
59
  delete(key) {