@graphql-mesh/cache-redis 0.103.8 → 0.103.9
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 +10 -1
- package/esm/index.js +10 -1
- package/package.json +1 -1
package/cjs/index.js
CHANGED
|
@@ -81,7 +81,7 @@ class RedisCache {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
getKeysByPrefix(prefix) {
|
|
84
|
-
return this.client
|
|
84
|
+
return scanPatterns(this.client, `${prefix}*`);
|
|
85
85
|
}
|
|
86
86
|
delete(key) {
|
|
87
87
|
try {
|
|
@@ -93,3 +93,12 @@ class RedisCache {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
exports.default = RedisCache;
|
|
96
|
+
function scanPatterns(redis, pattern, cursor = '0', keys = []) {
|
|
97
|
+
return (0, utils_1.mapMaybePromise)(redis.scan(cursor, 'MATCH', pattern, 'COUNT', '10'), ([nextCursor, nextKeys]) => {
|
|
98
|
+
keys.push(...nextKeys);
|
|
99
|
+
if (nextCursor === '0') {
|
|
100
|
+
return keys;
|
|
101
|
+
}
|
|
102
|
+
return scanPatterns(redis, pattern, nextCursor, keys);
|
|
103
|
+
});
|
|
104
|
+
}
|
package/esm/index.js
CHANGED
|
@@ -78,7 +78,7 @@ export default class RedisCache {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
getKeysByPrefix(prefix) {
|
|
81
|
-
return this.client
|
|
81
|
+
return scanPatterns(this.client, `${prefix}*`);
|
|
82
82
|
}
|
|
83
83
|
delete(key) {
|
|
84
84
|
try {
|
|
@@ -89,3 +89,12 @@ export default class RedisCache {
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
+
function scanPatterns(redis, pattern, cursor = '0', keys = []) {
|
|
93
|
+
return mapMaybePromise(redis.scan(cursor, 'MATCH', pattern, 'COUNT', '10'), ([nextCursor, nextKeys]) => {
|
|
94
|
+
keys.push(...nextKeys);
|
|
95
|
+
if (nextCursor === '0') {
|
|
96
|
+
return keys;
|
|
97
|
+
}
|
|
98
|
+
return scanPatterns(redis, pattern, nextCursor, keys);
|
|
99
|
+
});
|
|
100
|
+
}
|