redis-smq-common 1.0.5 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.0.0
4
+
5
+ * feat(redis-client): support offset and count for zrangebyscore() (2ec00e0)
6
+
7
+ ## 1.0.6 (2023-02-15)
8
+
9
+ * fix: use path.resolve() to fix 'no such file or directory' error (2d33599)
10
+
3
11
  ## 1.0.5 (2023-01-06)
4
12
 
5
13
  * chore: update license (9b817d2)
@@ -10,6 +10,7 @@ const fs = require("fs");
10
10
  const lock_manager_method_not_allowed_error_1 = require("./errors/lock-manager-method-not-allowed.error");
11
11
  const lock_manager_not_acquired_error_1 = require("./errors/lock-manager-not-acquired.error");
12
12
  const lock_manager_not_released_error_1 = require("./errors/lock-manager-not-released.error");
13
+ const path_1 = require("path");
13
14
  var ELockStatus;
14
15
  (function (ELockStatus) {
15
16
  ELockStatus[ELockStatus["unlocked"] = 0] = "unlocked";
@@ -24,8 +25,12 @@ var ELuaScript;
24
25
  ELuaScript["RELEASE_LOCK"] = "RELEASE_LOCK";
25
26
  ELuaScript["EXTEND_LOCK"] = "EXTEND_LOCK";
26
27
  })(ELuaScript = exports.ELuaScript || (exports.ELuaScript = {}));
27
- redis_client_1.RedisClient.addScript(ELuaScript.RELEASE_LOCK, fs.readFileSync(`${__dirname}/redis-client/lua/release-lock.lua`).toString());
28
- redis_client_1.RedisClient.addScript(ELuaScript.EXTEND_LOCK, fs.readFileSync(`${__dirname}/redis-client/lua/extend-lock.lua`).toString());
28
+ redis_client_1.RedisClient.addScript(ELuaScript.RELEASE_LOCK, fs
29
+ .readFileSync((0, path_1.resolve)(__dirname, './redis-client/lua/release-lock.lua'))
30
+ .toString());
31
+ redis_client_1.RedisClient.addScript(ELuaScript.EXTEND_LOCK, fs
32
+ .readFileSync((0, path_1.resolve)(__dirname, './redis-client/lua/extend-lock.lua'))
33
+ .toString());
29
34
  class LockManager {
30
35
  constructor(redisClient, lockKey, ttl, retryOnFail = false, autoExtend = false, throwExceptions = true) {
31
36
  this.status = ELockStatus.unlocked;
@@ -27,7 +27,7 @@ export declare class IoredisClient extends RedisClient {
27
27
  punsubscribe(channel: string): void;
28
28
  subscribe(channel: string): void;
29
29
  unsubscribe(channel: string): void;
30
- zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
30
+ zrangebyscore(key: string, min: number | string, max: number | string, offset: number, count: number, cb: ICallback<string[]>): void;
31
31
  smembers(key: string, cb: ICallback<string[]>): void;
32
32
  sadd(key: string, member: string, cb: ICallback<number>): void;
33
33
  srem(key: string, member: string, cb: ICallback<number>): void;
@@ -87,8 +87,8 @@ class IoredisClient extends redis_client_1.RedisClient {
87
87
  unsubscribe(channel) {
88
88
  this.client.unsubscribe(channel);
89
89
  }
90
- zrangebyscore(key, min, max, cb) {
91
- this.client.zrangebyscore(key, min, max, cb);
90
+ zrangebyscore(key, min, max, offset, count, cb) {
91
+ this.client.zrangebyscore(key, min, max, 'LIMIT', offset, count, cb);
92
92
  }
93
93
  smembers(key, cb) {
94
94
  this.client.smembers(key, cb);
@@ -27,7 +27,7 @@ export declare class NodeRedisV3Client extends RedisClient {
27
27
  punsubscribe(channel: string): void;
28
28
  subscribe(channel: string): void;
29
29
  unsubscribe(channel: string): void;
30
- zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
30
+ zrangebyscore(key: string, min: number | string, max: number | string, offset: number, count: number, cb: ICallback<string[]>): void;
31
31
  smembers(key: string, cb: ICallback<string[]>): void;
32
32
  sadd(key: string, member: string, cb: ICallback<number>): void;
33
33
  srem(key: string, member: string, cb: ICallback<number>): void;
@@ -114,8 +114,8 @@ class NodeRedisV3Client extends redis_client_1.RedisClient {
114
114
  unsubscribe(channel) {
115
115
  this.client.unsubscribe(channel);
116
116
  }
117
- zrangebyscore(key, min, max, cb) {
118
- this.client.zrangebyscore(key, min, max, cb);
117
+ zrangebyscore(key, min, max, offset, count, cb) {
118
+ this.client.zrangebyscore(key, min, max, 'LIMIT', offset, count, cb);
119
119
  }
120
120
  smembers(key, cb) {
121
121
  this.client.smembers(key, cb);
@@ -23,7 +23,7 @@ export declare class NodeRedisV4Client extends RedisClient {
23
23
  punsubscribe(channel: string): void;
24
24
  subscribe(channel: string): void;
25
25
  unsubscribe(channel: string): void;
26
- zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
26
+ zrangebyscore(key: string, min: number | string, max: number | string, offset: number, count: number, cb: ICallback<string[]>): void;
27
27
  smembers(key: string, cb: ICallback<string[]>): void;
28
28
  sscan(key: string, options: {
29
29
  MATCH?: string;
@@ -82,9 +82,14 @@ class NodeRedisV4Client extends redis_client_1.RedisClient {
82
82
  unsubscribe(channel) {
83
83
  this.client.unsubscribe(channel).catch(() => void 0);
84
84
  }
85
- zrangebyscore(key, min, max, cb) {
85
+ zrangebyscore(key, min, max, offset, count, cb) {
86
86
  this.client
87
- .zRangeByScore(key, min, max)
87
+ .zRangeByScore(key, min, max, {
88
+ LIMIT: {
89
+ offset,
90
+ count,
91
+ },
92
+ })
88
93
  .then((reply) => cb(null, reply))
89
94
  .catch(cb);
90
95
  }
@@ -31,7 +31,7 @@ export declare abstract class RedisClient extends EventEmitter {
31
31
  abstract punsubscribe(channel: string): void;
32
32
  abstract subscribe(channel: string): void;
33
33
  abstract unsubscribe(channel: string): void;
34
- abstract zrangebyscore(key: string, min: number | string, max: number | string, cb: ICallback<string[]>): void;
34
+ abstract zrangebyscore(key: string, min: number | string, max: number | string, offset: number, count: number, cb: ICallback<string[]>): void;
35
35
  abstract smembers(key: string, cb: ICallback<string[]>): void;
36
36
  abstract sscan(key: string, options: {
37
37
  MATCH?: string;
@@ -6,6 +6,7 @@ const lua_scripts_1 = require("./lua-scripts");
6
6
  const redis_client_error_1 = require("./errors/redis-client.error");
7
7
  const empty_callback_reply_error_1 = require("../errors/empty-callback-reply.error");
8
8
  const fs = require("fs");
9
+ const path_1 = require("path");
9
10
  var ELuaScriptName;
10
11
  (function (ELuaScriptName) {
11
12
  ELuaScriptName["LPOPRPUSH"] = "LPOPRPUSH";
@@ -103,7 +104,7 @@ exports.RedisClient = RedisClient;
103
104
  RedisClient.redisServerVersion = null;
104
105
  RedisClient.scriptsLoaded = false;
105
106
  RedisClient.luaScripts = new lua_scripts_1.LuaScripts();
106
- RedisClient.addScript(ELuaScriptName.ZPOPHGETRPUSH, fs.readFileSync(`${__dirname}/lua/zpophgetrpush.lua`).toString());
107
- RedisClient.addScript(ELuaScriptName.LPOPRPUSH, fs.readFileSync(`${__dirname}/lua/lpoprpush.lua`).toString());
108
- RedisClient.addScript(ELuaScriptName.LPOPRPUSHEXTRA, fs.readFileSync(`${__dirname}/lua/lpoprpushextra.lua`).toString());
107
+ RedisClient.addScript(ELuaScriptName.ZPOPHGETRPUSH, fs.readFileSync((0, path_1.resolve)(__dirname, './lua/zpophgetrpush.lua')).toString());
108
+ RedisClient.addScript(ELuaScriptName.LPOPRPUSH, fs.readFileSync((0, path_1.resolve)(__dirname, './lua/lpoprpush.lua')).toString());
109
+ RedisClient.addScript(ELuaScriptName.LPOPRPUSHEXTRA, fs.readFileSync((0, path_1.resolve)(__dirname, './lua/lpoprpushextra.lua')).toString());
109
110
  //# sourceMappingURL=redis-client.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redis-smq-common",
3
- "version": "1.0.5",
3
+ "version": "2.0.0",
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",