@graphql-mesh/cache-redis 0.103.20 → 0.103.21
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/cjs/index.js +3 -11
- package/esm/index.js +3 -11
- package/package.json +2 -3
package/cjs/index.js
CHANGED
|
@@ -5,7 +5,6 @@ const ioredis_1 = tslib_1.__importDefault(require("ioredis"));
|
|
|
5
5
|
const ioredis_mock_1 = tslib_1.__importDefault(require("ioredis-mock"));
|
|
6
6
|
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
7
7
|
const string_interpolation_1 = require("@graphql-mesh/string-interpolation");
|
|
8
|
-
const utils_1 = require("@graphql-mesh/utils");
|
|
9
8
|
const disposablestack_1 = require("@whatwg-node/disposablestack");
|
|
10
9
|
function interpolateStrWithEnv(str) {
|
|
11
10
|
return string_interpolation_1.stringInterpolator.parse(str, { env: cross_helpers_1.process.env });
|
|
@@ -94,25 +93,18 @@ class RedisCache {
|
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
get(key) {
|
|
97
|
-
return
|
|
98
|
-
return value != null ? JSON.parse(value) : undefined;
|
|
99
|
-
});
|
|
96
|
+
return this.client.get(key).then(value => (value != null ? JSON.parse(value) : undefined));
|
|
100
97
|
}
|
|
101
98
|
getKeysByPrefix(prefix) {
|
|
102
99
|
return scanPatterns(this.client, `${prefix}*`);
|
|
103
100
|
}
|
|
104
101
|
delete(key) {
|
|
105
|
-
|
|
106
|
-
return (0, utils_1.mapMaybePromise)(this.client.del(key), value => value > 0, () => false);
|
|
107
|
-
}
|
|
108
|
-
catch (e) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
102
|
+
return this.client.del(key).then(value => value > 0, () => false);
|
|
111
103
|
}
|
|
112
104
|
}
|
|
113
105
|
exports.default = RedisCache;
|
|
114
106
|
function scanPatterns(redis, pattern, cursor = '0', keys = []) {
|
|
115
|
-
return
|
|
107
|
+
return redis.scan(cursor, 'MATCH', pattern, 'COUNT', '10').then(([nextCursor, nextKeys]) => {
|
|
116
108
|
keys.push(...nextKeys);
|
|
117
109
|
if (nextCursor === '0') {
|
|
118
110
|
return keys;
|
package/esm/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import Redis from 'ioredis';
|
|
|
2
2
|
import RedisMock from 'ioredis-mock';
|
|
3
3
|
import { process } from '@graphql-mesh/cross-helpers';
|
|
4
4
|
import { stringInterpolator } from '@graphql-mesh/string-interpolation';
|
|
5
|
-
import { mapMaybePromise } from '@graphql-mesh/utils';
|
|
6
5
|
import { DisposableSymbols } from '@whatwg-node/disposablestack';
|
|
7
6
|
function interpolateStrWithEnv(str) {
|
|
8
7
|
return stringInterpolator.parse(str, { env: process.env });
|
|
@@ -91,24 +90,17 @@ export default class RedisCache {
|
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
get(key) {
|
|
94
|
-
return
|
|
95
|
-
return value != null ? JSON.parse(value) : undefined;
|
|
96
|
-
});
|
|
93
|
+
return this.client.get(key).then(value => (value != null ? JSON.parse(value) : undefined));
|
|
97
94
|
}
|
|
98
95
|
getKeysByPrefix(prefix) {
|
|
99
96
|
return scanPatterns(this.client, `${prefix}*`);
|
|
100
97
|
}
|
|
101
98
|
delete(key) {
|
|
102
|
-
|
|
103
|
-
return mapMaybePromise(this.client.del(key), value => value > 0, () => false);
|
|
104
|
-
}
|
|
105
|
-
catch (e) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
99
|
+
return this.client.del(key).then(value => value > 0, () => false);
|
|
108
100
|
}
|
|
109
101
|
}
|
|
110
102
|
function scanPatterns(redis, pattern, cursor = '0', keys = []) {
|
|
111
|
-
return
|
|
103
|
+
return redis.scan(cursor, 'MATCH', pattern, 'COUNT', '10').then(([nextCursor, nextKeys]) => {
|
|
112
104
|
keys.push(...nextKeys);
|
|
113
105
|
if (nextCursor === '0') {
|
|
114
106
|
return keys;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/cache-redis",
|
|
3
|
-
"version": "0.103.
|
|
3
|
+
"version": "0.103.21",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@graphql-mesh/cross-helpers": "^0.4.10",
|
|
10
10
|
"@graphql-mesh/string-interpolation": "0.5.8",
|
|
11
|
-
"@graphql-mesh/types": "^0.103.
|
|
12
|
-
"@graphql-mesh/utils": "^0.103.19",
|
|
11
|
+
"@graphql-mesh/types": "^0.103.20",
|
|
13
12
|
"@whatwg-node/disposablestack": "^0.0.5",
|
|
14
13
|
"ioredis": "^5.3.2",
|
|
15
14
|
"ioredis-mock": "^8.8.3",
|