@tmlmobilidade/databases 20260602.2322.45 → 20260602.2346.23
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.
|
@@ -76,11 +76,14 @@ class ApiCacheClass {
|
|
|
76
76
|
* @returns A promise resolving with all matching keys.
|
|
77
77
|
*/
|
|
78
78
|
async scan(pattern) {
|
|
79
|
-
const
|
|
80
|
-
for await (const
|
|
81
|
-
keys
|
|
79
|
+
const foundKeys = new Set();
|
|
80
|
+
for await (const scanResult of this.client.scanIterator({ MATCH: pattern, TYPE: 'string' })) {
|
|
81
|
+
// Scan result is an array of keys because Redis just goes over all keys
|
|
82
|
+
// in the database without any specific order or pagination and returns
|
|
83
|
+
// only the ones that match the requested pattern.
|
|
84
|
+
scanResult.forEach(key => foundKeys.add(key));
|
|
82
85
|
}
|
|
83
|
-
return
|
|
86
|
+
return Array.from(foundKeys);
|
|
84
87
|
}
|
|
85
88
|
/**
|
|
86
89
|
* Saves a cache entry with an optional time-to-live (TTL).
|