@imqueue/rpc 1.13.10 → 1.13.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/package.json
CHANGED
|
@@ -28,12 +28,7 @@ export declare const DEFAULT_REDIS_CACHE_OPTIONS: {
|
|
|
28
28
|
port?: number | undefined;
|
|
29
29
|
vendor?: string | undefined;
|
|
30
30
|
logger?: ILogger | undefined;
|
|
31
|
-
watcherCheckDelay?: number | undefined;
|
|
32
|
-
* Returns value stored in cache by a given key
|
|
33
|
-
*
|
|
34
|
-
* @param {string} key
|
|
35
|
-
* @returns {Promise<any>}
|
|
36
|
-
*/
|
|
31
|
+
watcherCheckDelay?: number | undefined;
|
|
37
32
|
useGzip?: boolean | undefined;
|
|
38
33
|
safeDelivery?: boolean | undefined;
|
|
39
34
|
safeDeliveryTtl?: number | undefined;
|
|
@@ -78,7 +73,7 @@ export declare class RedisCache implements ICache {
|
|
|
78
73
|
* Stores in cache given value under given key. If TTL is specified,
|
|
79
74
|
* cached value will expire in a given number of milliseconds. If NX
|
|
80
75
|
* argument set to true will create key:value in cache only if it does
|
|
81
|
-
* not
|
|
76
|
+
* not exist yet. Given value could be any JSON-compatible object and
|
|
82
77
|
* will be serialized automatically.
|
|
83
78
|
*
|
|
84
79
|
* @param {string} key
|
package/src/cache/RedisCache.js
CHANGED
|
@@ -36,7 +36,12 @@ class RedisCache {
|
|
|
36
36
|
RedisCache.redis = core_1.redis.createClient(Number(this.options.port), String(this.options.host));
|
|
37
37
|
RedisCache.redis.on('ready', async () => {
|
|
38
38
|
this.logger.info('%s: redis cache connected, host %s:%s, pid %s', this.name, this.options.host, this.options.port, process.pid);
|
|
39
|
-
|
|
39
|
+
try {
|
|
40
|
+
await RedisCache.redis.client('setname', `${this.options.prefix}:${this.name}:pid:${process.pid}:host:${os.hostname()}`);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
this.logger.warn('Redis client command error:', err);
|
|
44
|
+
}
|
|
40
45
|
this.ready = true;
|
|
41
46
|
resolve(this);
|
|
42
47
|
});
|
|
@@ -67,6 +72,7 @@ class RedisCache {
|
|
|
67
72
|
if (!RedisCache.redis) {
|
|
68
73
|
throw new TypeError(exports.REDIS_CLIENT_INIT_ERROR);
|
|
69
74
|
}
|
|
75
|
+
// noinspection ES6RedundantAwait
|
|
70
76
|
const data = await RedisCache.redis.get(this.key(key));
|
|
71
77
|
if (data) {
|
|
72
78
|
return JSON.parse(data);
|
|
@@ -77,7 +83,7 @@ class RedisCache {
|
|
|
77
83
|
* Stores in cache given value under given key. If TTL is specified,
|
|
78
84
|
* cached value will expire in a given number of milliseconds. If NX
|
|
79
85
|
* argument set to true will create key:value in cache only if it does
|
|
80
|
-
* not
|
|
86
|
+
* not exist yet. Given value could be any JSON-compatible object and
|
|
81
87
|
* will be serialized automatically.
|
|
82
88
|
*
|
|
83
89
|
* @param {string} key
|
|
@@ -125,6 +131,7 @@ class RedisCache {
|
|
|
125
131
|
throw new TypeError(exports.REDIS_CLIENT_INIT_ERROR);
|
|
126
132
|
}
|
|
127
133
|
try {
|
|
134
|
+
// noinspection SpellCheckingInspection
|
|
128
135
|
await RedisCache.redis.eval(`for _,k in ipairs(redis.call('keys','${keyMask}')) do redis.call('del',k) end`, 0);
|
|
129
136
|
return true;
|
|
130
137
|
}
|