redis-smq-common 1.0.0-rc.10 → 1.0.0-rc.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.0.0-rc.11 (2022-05-31)
4
+
5
+ * Update RedisClient and IRedisClientMulti interfaces (8732c97)
6
+
3
7
  ## 1.0.0-rc.10 (2022-05-31)
4
8
 
5
9
  * Fix broken promisify(All) because of ICallback typing (4250e32)
@@ -10,12 +10,14 @@ export declare class IoredisClientMulti implements IRedisClientMulti {
10
10
  rpop(key: string): this;
11
11
  rpush(key: string, element: string): this;
12
12
  zadd(key: string, score: number, element: string): this;
13
- zrem(key: string, element: string): this;
13
+ zrem(key: string, element: string | string[]): this;
14
14
  sadd(key: string, element: string): this;
15
15
  srem(key: string, element: string | string[]): this;
16
16
  hset(key: string, field: string, value: string): this;
17
- hdel(key: string, field: string): this;
17
+ hdel(key: string, field: string | string[]): this;
18
+ hincrby(key: string, field: string, by: number): this;
18
19
  pexpire(key: string, millis: number): this;
20
+ expire(key: string, secs: number): this;
19
21
  rpoplpush(source: string, destination: string): this;
20
22
  del(key: string | string[]): this;
21
23
  exec(cb: ICallback<unknown[]>): void;
@@ -36,7 +36,7 @@ class IoredisClientMulti {
36
36
  return this;
37
37
  }
38
38
  zrem(key, element) {
39
- this.multi.zrem(key, element);
39
+ this.multi.zrem(key, ...(typeof element === 'string' ? [element] : element));
40
40
  return this;
41
41
  }
42
42
  sadd(key, element) {
@@ -52,13 +52,21 @@ class IoredisClientMulti {
52
52
  return this;
53
53
  }
54
54
  hdel(key, field) {
55
- this.multi.hdel(key, field);
55
+ this.multi.hdel(key, ...(typeof field === 'string' ? [field] : field));
56
+ return this;
57
+ }
58
+ hincrby(key, field, by) {
59
+ this.multi.hincrby(key, field, by);
56
60
  return this;
57
61
  }
58
62
  pexpire(key, millis) {
59
63
  this.multi.pexpire(key, millis);
60
64
  return this;
61
65
  }
66
+ expire(key, secs) {
67
+ this.multi.expire(key, secs);
68
+ return this;
69
+ }
62
70
  rpoplpush(source, destination) {
63
71
  this.multi.rpoplpush(source, destination);
64
72
  return this;
@@ -21,6 +21,8 @@ export declare class IoredisClient extends RedisClient {
21
21
  zrange(key: string, min: number, max: number, cb: ICallback<string[]>): void;
22
22
  psubscribe(pattern: string): void;
23
23
  punsubscribe(channel: string): void;
24
+ subscribe(channel: string): void;
25
+ unsubscribe(channel: string): void;
24
26
  zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
25
27
  smembers(key: string, cb: ICallback<string[]>): void;
26
28
  sadd(key: string, member: string, cb: ICallback<number>): void;
@@ -59,6 +59,12 @@ class IoredisClient extends redis_client_1.RedisClient {
59
59
  punsubscribe(channel) {
60
60
  this.client.punsubscribe(channel);
61
61
  }
62
+ subscribe(channel) {
63
+ this.client.subscribe(channel);
64
+ }
65
+ unsubscribe(channel) {
66
+ this.client.unsubscribe(channel);
67
+ }
62
68
  zrangebyscore(key, min, max, cb) {
63
69
  this.client.zrangebyscore(key, min, max, cb);
64
70
  }
@@ -10,12 +10,14 @@ export declare class NodeRedisV3ClientMulti implements IRedisClientMulti {
10
10
  rpop(key: string): this;
11
11
  rpush(key: string, element: string): this;
12
12
  zadd(key: string, score: number, element: string): this;
13
- zrem(key: string, element: string): this;
13
+ zrem(key: string, element: string | string[]): this;
14
14
  sadd(key: string, element: string): this;
15
15
  srem(key: string, element: string | string[]): this;
16
16
  hset(key: string, field: string, value: string): this;
17
- hdel(key: string, field: string): this;
17
+ hdel(key: string, field: string | string[]): this;
18
+ hincrby(key: string, field: string, by: number): this;
18
19
  pexpire(key: string, millis: number): this;
20
+ expire(key: string, secs: number): this;
19
21
  rpoplpush(source: string, destination: string): this;
20
22
  del(key: string | string[]): this;
21
23
  exec(cb: ICallback<unknown[]>): void;
@@ -54,10 +54,18 @@ class NodeRedisV3ClientMulti {
54
54
  this.multi.hdel(key, field);
55
55
  return this;
56
56
  }
57
+ hincrby(key, field, by) {
58
+ this.multi.hincrby(key, field, by);
59
+ return this;
60
+ }
57
61
  pexpire(key, millis) {
58
62
  this.multi.pexpire(key, millis);
59
63
  return this;
60
64
  }
65
+ expire(key, secs) {
66
+ this.multi.expire(key, secs);
67
+ return this;
68
+ }
61
69
  rpoplpush(source, destination) {
62
70
  this.multi.rpoplpush(source, destination);
63
71
  return this;
@@ -21,6 +21,8 @@ export declare class NodeRedisV3Client extends RedisClient {
21
21
  zrange(key: string, min: number, max: number, cb: ICallback<string[]>): void;
22
22
  psubscribe(pattern: string): void;
23
23
  punsubscribe(channel: string): void;
24
+ subscribe(channel: string): void;
25
+ unsubscribe(channel: string): void;
24
26
  zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
25
27
  smembers(key: string, cb: ICallback<string[]>): void;
26
28
  sadd(key: string, member: string, cb: ICallback<number>): void;
@@ -86,6 +86,12 @@ class NodeRedisV3Client extends redis_client_1.RedisClient {
86
86
  punsubscribe(channel) {
87
87
  this.client.punsubscribe(channel);
88
88
  }
89
+ subscribe(channel) {
90
+ this.client.subscribe(channel);
91
+ }
92
+ unsubscribe(channel) {
93
+ this.client.unsubscribe(channel);
94
+ }
89
95
  zrangebyscore(key, min, max, cb) {
90
96
  this.client.zrangebyscore(key, min, max, cb);
91
97
  }
@@ -9,12 +9,14 @@ export declare class NodeRedisV4ClientMulti implements IRedisClientMulti {
9
9
  rpop(key: string): this;
10
10
  rpush(key: string, element: string): this;
11
11
  zadd(key: string, score: number, element: string): this;
12
- zrem(key: string, element: string): this;
12
+ zrem(key: string, element: string | string[]): this;
13
13
  sadd(key: string, element: string): this;
14
14
  srem(key: string, element: string | string[]): this;
15
15
  hset(key: string, field: string, value: string): this;
16
- hdel(key: string, field: string): this;
16
+ hdel(key: string, field: string | string[]): this;
17
+ hincrby(key: string, field: string, by: number): this;
17
18
  pexpire(key: string, millis: number): this;
19
+ expire(key: string, secs: number): this;
18
20
  rpoplpush(source: string, destination: string): this;
19
21
  del(key: string | string[]): this;
20
22
  exec(cb: ICallback<unknown[]>): void;
@@ -55,10 +55,18 @@ class NodeRedisV4ClientMulti {
55
55
  this.multi.hDel(key, field);
56
56
  return this;
57
57
  }
58
+ hincrby(key, field, by) {
59
+ this.multi.hIncrBy(key, field, by);
60
+ return this;
61
+ }
58
62
  pexpire(key, millis) {
59
63
  this.multi.pExpire(key, millis);
60
64
  return this;
61
65
  }
66
+ expire(key, secs) {
67
+ this.multi.expire(key, secs);
68
+ return this;
69
+ }
62
70
  rpoplpush(source, destination) {
63
71
  this.multi.rPopLPush(source, destination);
64
72
  return this;
@@ -21,6 +21,8 @@ export declare class NodeRedisV4Client extends RedisClient {
21
21
  zrange(key: string, min: number, max: number, cb: ICallback<string[]>): void;
22
22
  psubscribe(pattern: string): void;
23
23
  punsubscribe(channel: string): void;
24
+ subscribe(channel: string): void;
25
+ unsubscribe(channel: string): void;
24
26
  zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
25
27
  smembers(key: string, cb: ICallback<string[]>): void;
26
28
  sadd(key: string, member: string, cb: ICallback<number>): void;
@@ -74,6 +74,14 @@ class NodeRedisV4Client extends redis_client_1.RedisClient {
74
74
  punsubscribe(channel) {
75
75
  this.client.pUnsubscribe(channel).catch(() => void 0);
76
76
  }
77
+ subscribe(channel) {
78
+ this.client.subscribe(channel, (message, channel) => {
79
+ this.client.emit('message', channel, message);
80
+ });
81
+ }
82
+ unsubscribe(channel) {
83
+ this.client.unsubscribe(channel).catch(() => void 0);
84
+ }
77
85
  zrangebyscore(key, min, max, cb) {
78
86
  this.client
79
87
  .zRangeByScore(key, min, max)
@@ -29,6 +29,8 @@ export declare abstract class RedisClient extends EventEmitter {
29
29
  abstract zrange(key: string, min: number, max: number, cb: ICallback<string[]>): void;
30
30
  abstract psubscribe(pattern: string): void;
31
31
  abstract punsubscribe(channel: string): void;
32
+ abstract subscribe(channel: string): void;
33
+ abstract unsubscribe(channel: string): void;
32
34
  abstract zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
33
35
  abstract smembers(key: string, cb: ICallback<string[]>): void;
34
36
  abstract sadd(key: string, member: string, cb: ICallback<number>): void;
@@ -29,14 +29,16 @@ export interface IRedisClientMulti {
29
29
  rpush(key: string, element: string): this;
30
30
  rpop(key: string): this;
31
31
  lpush(key: string, element: string): this;
32
- hdel(key: string, field: string): this;
32
+ hdel(key: string, field: string | string[]): this;
33
+ hincrby(key: string, field: string, by: number): this;
33
34
  del(key: string | string[]): this;
34
35
  srem(key: string, element: string | string[]): this;
35
36
  sadd(key: string, element: string): this;
36
- zrem(key: string, element: string): this;
37
+ zrem(key: string, element: string | string[]): this;
37
38
  zadd(key: string, score: number, element: string): this;
38
39
  hset(key: string, field: string, value: string): this;
39
40
  pexpire(key: string, millis: number): this;
41
+ expire(key: string, secs: number): this;
40
42
  ltrim(key: string, start: number, stop: number): this;
41
43
  rpoplpush(source: string, destination: string): this;
42
44
  exec(cb: ICallback<unknown[]>): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redis-smq-common",
3
- "version": "1.0.0-rc.10",
3
+ "version": "1.0.0-rc.11",
4
4
  "description": "RedisSMQ shared components that may be used by integrated applications and extensions.",
5
5
  "author": "Weyoss <weyoss@protonmail.com>",
6
6
  "license": "MIT",