aboutsummaryrefslogtreecommitdiff
path: root/utils/getRedisWithPrefix.js
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-10-22 19:43:17 +0700
committerGitHub <[email protected]>2023-10-22 19:43:17 +0700
commitf801f8f422954b884a6541321dba0669ee9d6173 (patch)
treee0d5e106b99e9b4e0a4c4bf7bb0464617db85b8d /utils/getRedisWithPrefix.js
parentBump @babel/traverse from 7.22.8 to 7.23.2 (#90) (diff)
downloadmoopa-4.2.0.tar.xz
moopa-4.2.0.zip
Update v4.2.0 (#93)v4.2.0
Diffstat (limited to 'utils/getRedisWithPrefix.js')
-rw-r--r--utils/getRedisWithPrefix.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/utils/getRedisWithPrefix.js b/utils/getRedisWithPrefix.js
index 31a466d..b85589b 100644
--- a/utils/getRedisWithPrefix.js
+++ b/utils/getRedisWithPrefix.js
@@ -63,6 +63,19 @@ export async function getValuesWithNumericKeys() {
return values;
}
+export async function getKeysWithNumericKeys() {
+ const allKeys = await redis.keys("*"); // Fetch all keys in Redis
+ const numericKeys = allKeys.filter((key) => /^\d+$/.test(key)); // Filter keys that contain only numbers
+
+ const values = [];
+
+ for (const key of numericKeys) {
+ const value = await redis.del(key);
+ }
+
+ return values;
+}
+
export async function countNumericKeys() {
const allKeys = await redis.keys("*"); // Fetch all keys in Redis
const numericKeys = allKeys.filter((key) => /^\d+$/.test(key)); // Filter keys that contain only numbers