@autofleet/matmon 2.0.4 → 2.0.6
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/lib/redis/index.js +10 -8
- package/package.json +1 -1
package/lib/redis/index.js
CHANGED
|
@@ -47,6 +47,14 @@ class RedisCache {
|
|
|
47
47
|
get(key) {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
const keyWithPrefix = KEY_PREFIX + key;
|
|
50
|
+
let value;
|
|
51
|
+
try {
|
|
52
|
+
// Try to get the value from redis.
|
|
53
|
+
value = yield this.client.getAsync(keyWithPrefix);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
throw new errors_1.RedisCacheError('Failed to get a value', err);
|
|
57
|
+
}
|
|
50
58
|
if (this.useLock) {
|
|
51
59
|
let lock;
|
|
52
60
|
try {
|
|
@@ -59,14 +67,6 @@ class RedisCache {
|
|
|
59
67
|
// If the lock did not fail, add it to a locks dictionary.
|
|
60
68
|
this.locks[keyWithPrefix] = lock;
|
|
61
69
|
}
|
|
62
|
-
let value;
|
|
63
|
-
try {
|
|
64
|
-
// Try to get the value from redis.
|
|
65
|
-
value = yield this.client.getAsync(keyWithPrefix);
|
|
66
|
-
}
|
|
67
|
-
catch (err) {
|
|
68
|
-
throw new errors_1.RedisCacheError('Failed to get a value', err);
|
|
69
|
-
}
|
|
70
70
|
return JSON.parse(value);
|
|
71
71
|
});
|
|
72
72
|
}
|
|
@@ -78,6 +78,7 @@ class RedisCache {
|
|
|
78
78
|
yield this.client.setAsync(keyWithPrefix, JSON.stringify(value), 'EX', ttl);
|
|
79
79
|
if (this.locks[keyWithPrefix]) {
|
|
80
80
|
yield this.locks[keyWithPrefix]();
|
|
81
|
+
delete this.locks[keyWithPrefix];
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
catch (err) {
|
|
@@ -91,6 +92,7 @@ class RedisCache {
|
|
|
91
92
|
try {
|
|
92
93
|
if (this.locks[keyWithPrefix]) {
|
|
93
94
|
yield this.locks[keyWithPrefix]();
|
|
95
|
+
delete this.locks[keyWithPrefix];
|
|
94
96
|
}
|
|
95
97
|
yield this.client.delAsync(keyWithPrefix);
|
|
96
98
|
}
|