@keyv/redis 5.1.5 → 6.0.0-alpha.1

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
@@ -419,34 +419,42 @@ You can learn more about the `createCluster` function in the [documentation](htt
419
419
 
420
420
  # Sentinel
421
421
 
422
- If you are using Sentinel to provide high availability for your Redis instances, you can pass in the `redisOptions` directly. Here is an example of how to do that:
422
+ If you are using Sentinel to provide high availability for your Redis instances, you can pass in the sentinel options directly to the `KeyvRedis` constructor:
423
423
 
424
424
  ```js
425
425
  import Keyv from 'keyv';
426
- import KeyvRedis, { createSentinel } from '@keyv/redis';
426
+ import KeyvRedis from '@keyv/redis';
427
427
 
428
- const sentinel = createSentinel({
429
- name: 'sentinel-db',
428
+ const keyv = new Keyv({
429
+ store: new KeyvRedis({
430
+ name: 'mymaster',
430
431
  sentinelRootNodes: [
431
- {
432
- host: '127.0.0.1',
433
- port: 26379,
434
- },
435
- {
436
- host: '127.0.0.1',
437
- port: 26380,
438
- },
439
- {
440
- host: '127.0.0.1',
441
- port: 26381,
442
- },
432
+ { host: '127.0.0.1', port: 26379 },
433
+ { host: '127.0.0.1', port: 26380 },
434
+ { host: '127.0.0.1', port: 26381 },
443
435
  ],
436
+ }),
444
437
  });
438
+ ```
439
+
440
+ For TypeScript users, the `RedisSentinelOptions` type is exported from the package:
441
+
442
+ ```typescript
443
+ import KeyvRedis, { type RedisSentinelOptions } from '@keyv/redis';
444
+
445
+ const sentinelOptions: RedisSentinelOptions = {
446
+ name: 'mymaster',
447
+ sentinelRootNodes: [
448
+ { host: '127.0.0.1', port: 26379 },
449
+ { host: '127.0.0.1', port: 26380 },
450
+ { host: '127.0.0.1', port: 26381 },
451
+ ],
452
+ };
445
453
 
446
- const keyv = new Keyv({ store: new KeyvRedis(sentinel) });
454
+ const keyvRedis = new KeyvRedis(sentinelOptions);
447
455
  ```
448
456
 
449
- You can learn more about the `createSentinel` function in the [documentation](https://github.com/redis/node-redis/blob/master/docs/sentinel.md) at https://github.com/redis/node-redis/tree/master/docs.
457
+ You can learn more about Sentinel configuration in the [documentation](https://github.com/redis/node-redis/blob/master/docs/sentinel.md) at https://github.com/redis/node-redis/tree/master/docs.
450
458
 
451
459
  # TLS Support
452
460
 
package/dist/index.cjs CHANGED
@@ -107,7 +107,7 @@ function createKeyvNonBlocking(connect, options) {
107
107
 
108
108
  // src/index.ts
109
109
  var KeyvRedis = class extends import_hookified.Hookified {
110
- _client = (0, import_client.createClient)();
110
+ _client;
111
111
  _namespace;
112
112
  _keyPrefixSeparator = "::";
113
113
  _clearBatchSize = 1e3;
@@ -154,6 +154,8 @@ var KeyvRedis = class extends import_hookified.Hookified {
154
154
  this._client = (0, import_client.createCluster)(connect);
155
155
  }
156
156
  }
157
+ } else {
158
+ this._client = (0, import_client.createClient)({ socket });
157
159
  }
158
160
  this.setOptions(options);
159
161
  this.initClient();
@@ -870,6 +872,9 @@ var KeyvRedis = class extends import_hookified.Hookified {
870
872
  }
871
873
  }
872
874
  initClient() {
875
+ this._client.on("error", (error) => {
876
+ this.emit("error", error);
877
+ });
873
878
  this._client.on("connect", () => {
874
879
  this.emit("connect", this._client);
875
880
  });
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RedisClientType, RedisModules, RedisFunctions, RedisScripts, RespVersions, TypeMapping, RedisClusterType, RedisSentinelType, RedisClientOptions, RedisClusterOptions, RedisSentinelOptions } from '@redis/client';
2
- export { RedisClientOptions, RedisClientType, RedisClusterOptions, RedisClusterType, RedisSentinelType, createClient, createCluster, createSentinel } from '@redis/client';
2
+ export { RedisClientOptions, RedisClientType, RedisClusterOptions, RedisClusterType, RedisSentinelOptions, RedisSentinelType, createClient, createCluster, createSentinel } from '@redis/client';
3
3
  import { Hookified } from 'hookified';
4
4
  import { Keyv, KeyvStoreAdapter, KeyvEntry } from 'keyv';
5
5
  export { Keyv } from 'keyv';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RedisClientType, RedisModules, RedisFunctions, RedisScripts, RespVersions, TypeMapping, RedisClusterType, RedisSentinelType, RedisClientOptions, RedisClusterOptions, RedisSentinelOptions } from '@redis/client';
2
- export { RedisClientOptions, RedisClientType, RedisClusterOptions, RedisClusterType, RedisSentinelType, createClient, createCluster, createSentinel } from '@redis/client';
2
+ export { RedisClientOptions, RedisClientType, RedisClusterOptions, RedisClusterType, RedisSentinelOptions, RedisSentinelType, createClient, createCluster, createSentinel } from '@redis/client';
3
3
  import { Hookified } from 'hookified';
4
4
  import { Keyv, KeyvStoreAdapter, KeyvEntry } from 'keyv';
5
5
  export { Keyv } from 'keyv';
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ function createKeyvNonBlocking(connect, options) {
73
73
 
74
74
  // src/index.ts
75
75
  var KeyvRedis = class extends Hookified {
76
- _client = createClient();
76
+ _client;
77
77
  _namespace;
78
78
  _keyPrefixSeparator = "::";
79
79
  _clearBatchSize = 1e3;
@@ -120,6 +120,8 @@ var KeyvRedis = class extends Hookified {
120
120
  this._client = createCluster(connect);
121
121
  }
122
122
  }
123
+ } else {
124
+ this._client = createClient({ socket });
123
125
  }
124
126
  this.setOptions(options);
125
127
  this.initClient();
@@ -836,6 +838,9 @@ var KeyvRedis = class extends Hookified {
836
838
  }
837
839
  }
838
840
  initClient() {
841
+ this._client.on("error", (error) => {
842
+ this.emit("error", error);
843
+ });
839
844
  this._client.on("connect", () => {
840
845
  this.emit("connect", this._client);
841
846
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyv/redis",
3
- "version": "5.1.5",
3
+ "version": "6.0.0-alpha.1",
4
4
  "description": "Redis storage adapter for Keyv",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -45,17 +45,17 @@
45
45
  "hookified": "^1.13.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "keyv": "^5.5.5"
48
+ "keyv": "^6.0.0-alpha.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@biomejs/biome": "^2.3.8",
52
- "@faker-js/faker": "^10.1.0",
53
- "@vitest/coverage-v8": "^4.0.15",
51
+ "@biomejs/biome": "^2.3.11",
52
+ "@faker-js/faker": "^10.2.0",
53
+ "@vitest/coverage-v8": "^4.0.16",
54
54
  "rimraf": "^6.1.2",
55
55
  "timekeeper": "^2.3.1",
56
56
  "tsd": "^0.33.0",
57
- "vitest": "^4.0.15",
58
- "@keyv/test-suite": "^2.1.2"
57
+ "vitest": "^4.0.16",
58
+ "@keyv/test-suite": "^6.0.0-alpha.1"
59
59
  },
60
60
  "tsd": {
61
61
  "directory": "test"