ioredis 5.6.1 → 5.7.0

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
@@ -262,7 +262,7 @@ async function listenForMessage(lastId = "$") {
262
262
  // `results` is an array, each element of which corresponds to a key.
263
263
  // Because we only listen to one key (mystream) here, `results` only contains
264
264
  // a single element. See more: https://redis.io/commands/xread#return-value
265
- const results = await redis.xread("block", 0, "STREAMS", "mystream", lastId);
265
+ const results = await redis.xread("BLOCK", 0, "STREAMS", "mystream", lastId);
266
266
  const [key, messages] = results[0]; // `key` equals to "mystream"
267
267
 
268
268
  messages.forEach(processMessage);
@@ -826,7 +826,7 @@ The Redis instance will emit some events about the state of the connection to th
826
826
  | :----------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
827
827
  | connect | emits when a connection is established to the Redis server. |
828
828
  | ready | If `enableReadyCheck` is `true`, client will emit `ready` when the server reports that it is ready to receive commands (e.g. finish loading data from disk).<br>Otherwise, `ready` will be emitted immediately right after the `connect` event. |
829
- | error | emits when an error occurs while connecting.<br>However, ioredis emits all `error` events silently (only emits when there's at least one listener) so that your application won't crash if you're not listening to the `error` event. |
829
+ | error | emits when an error occurs while connecting.<br>However, ioredis emits all `error` events silently (only emits when there's at least one listener) so that your application won't crash if you're not listening to the `error` event.<br>When `redis.connect()` is explicitly called the error will also be rejected from the returned promise, in addition to emitting it. If `redis.connect()` is not called explicitly and `lazyConnect` is true, ioredis will try to connect automatically on the first command and emit the `error` event silently. |
830
830
  | close | emits when an established Redis server connection has closed. |
831
831
  | reconnecting | emits after `close` when a reconnection will be made. The argument of the event is the time (in ms) before reconnecting. |
832
832
  | end | emits after `close` when no more reconnections will be made, or the connection is failed to establish. |
@@ -1149,7 +1149,7 @@ const cluster = new Redis.Cluster(
1149
1149
  ],
1150
1150
  {
1151
1151
  natMap: (key) => {
1152
- if(key.indexOf('30001')) {
1152
+ if(key.includes('30001')) {
1153
1153
  return { host: "203.0.113.73", port: 30001 };
1154
1154
  }
1155
1155
 
package/built/Redis.d.ts CHANGED
@@ -81,7 +81,8 @@ declare class Redis extends Commander implements DataHandledable {
81
81
  * unless `lazyConnect: true` is passed.
82
82
  *
83
83
  * When calling this method manually, a Promise is returned, which will
84
- * be resolved when the connection status is ready.
84
+ * be resolved when the connection status is ready. The promise can reject
85
+ * if the connection fails, times out, or if Redis is already connecting/connected.
85
86
  */
86
87
  connect(callback?: Callback<void>): Promise<void>;
87
88
  /**
package/built/Redis.js CHANGED
@@ -97,7 +97,8 @@ class Redis extends Commander_1.default {
97
97
  * unless `lazyConnect: true` is passed.
98
98
  *
99
99
  * When calling this method manually, a Promise is returned, which will
100
- * be resolved when the connection status is ready.
100
+ * be resolved when the connection status is ready. The promise can reject
101
+ * if the connection fails, times out, or if Redis is already connecting/connected.
101
102
  */
102
103
  connect(callback) {
103
104
  const promise = new Promise((resolve, reject) => {
@@ -154,7 +154,8 @@ export interface CommonRedisOptions extends CommanderOptions {
154
154
  /**
155
155
  * When a Redis instance is initialized, a connection to the server is immediately established. Set this to
156
156
  * true will delay the connection to the server until the first command is sent or `redis.connect()` is called
157
- * explicitly.
157
+ * explicitly. When `redis.connect()` is called explicitly, a Promise is returned, which will be resolved
158
+ * when the connection is ready or rejected when it fails. The rejection should be handled by the user.
158
159
  *
159
160
  * @default false
160
161
  */
@@ -2247,6 +2247,22 @@ interface RedisCommander<Context extends ClientContext = {
2247
2247
  * - _since_: 2.0.0
2248
2248
  */
2249
2249
  hexists(key: RedisKey, field: string | Buffer, callback?: Callback<number>): Result<number, Context>;
2250
+ /**
2251
+ * Set expiry for hash field using relative time to expire (seconds)
2252
+ * - _group_: hash
2253
+ * - _complexity_: O(N) where N is the number of specified fields
2254
+ * - _since_: 7.4.0
2255
+ */
2256
+ hexpire(...args: [key: RedisKey, seconds: number | string, fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[], callback: Callback<number[]>]): Result<number[], Context>;
2257
+ hexpire(...args: [key: RedisKey, seconds: number | string, fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[]]): Result<number[], Context>;
2258
+ hexpire(...args: [key: RedisKey, seconds: number | string, nx: 'NX', fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[], callback: Callback<number[]>]): Result<number[], Context>;
2259
+ hexpire(...args: [key: RedisKey, seconds: number | string, nx: 'NX', fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[]]): Result<number[], Context>;
2260
+ hexpire(...args: [key: RedisKey, seconds: number | string, xx: 'XX', fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[], callback: Callback<number[]>]): Result<number[], Context>;
2261
+ hexpire(...args: [key: RedisKey, seconds: number | string, xx: 'XX', fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[]]): Result<number[], Context>;
2262
+ hexpire(...args: [key: RedisKey, seconds: number | string, gt: 'GT', fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[], callback: Callback<number[]>]): Result<number[], Context>;
2263
+ hexpire(...args: [key: RedisKey, seconds: number | string, gt: 'GT', fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[]]): Result<number[], Context>;
2264
+ hexpire(...args: [key: RedisKey, seconds: number | string, lt: 'LT', fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[], callback: Callback<number[]>]): Result<number[], Context>;
2265
+ hexpire(...args: [key: RedisKey, seconds: number | string, lt: 'LT', fieldsToken: 'FIELDS', numfields: number | string, ...fields: (string | Buffer)[]]): Result<number[], Context>;
2250
2266
  /**
2251
2267
  * Get the value of a hash field
2252
2268
  * - _group_: hash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ioredis",
3
- "version": "5.6.1",
3
+ "version": "5.7.0",
4
4
  "description": "A robust, performance-focused and full-featured Redis client for Node.js.",
5
5
  "main": "./built/index.js",
6
6
  "types": "./built/index.d.ts",
@@ -41,7 +41,7 @@
41
41
  "url": "https://opencollective.com/ioredis"
42
42
  },
43
43
  "dependencies": {
44
- "@ioredis/commands": "^1.1.1",
44
+ "@ioredis/commands": "^1.3.0",
45
45
  "cluster-key-slot": "^1.1.0",
46
46
  "debug": "^4.3.4",
47
47
  "denque": "^2.1.0",