-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclear-round1-redis.js
More file actions
51 lines (41 loc) · 1.77 KB
/
clear-round1-redis.js
File metadata and controls
51 lines (41 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import redis from "./config/redis.js";
async function clearRound1RedisState() {
try {
console.log("🧹 Clearing Redis state for Round 1...");
// Define all Round 1 Redis keys based on the handler
const round1Keys = [
"round1:participants",
"round1:readyQueue",
"round1:matches",
"round1:status",
"round1:startTime"
];
// Get all keys that match round1:user:* pattern (user presence keys)
const userPresenceKeys = await redis.keys("round1:user:*");
// Combine all keys to delete
const allKeysToDelete = [...round1Keys, ...userPresenceKeys];
console.log(`📝 Found ${allKeysToDelete.length} keys to delete:`);
allKeysToDelete.forEach(key => console.log(` - ${key}`));
if (allKeysToDelete.length > 0) {
// Delete all keys
const deletedCount = await redis.del(...allKeysToDelete);
console.log(`✅ Successfully deleted ${deletedCount} Redis keys for Round 1`);
} else {
console.log("ℹ️ No Round 1 keys found in Redis");
}
// Verify deletion
console.log("\n🔍 Verifying deletion:");
for (const key of round1Keys) {
const exists = await redis.exists(key);
console.log(` ${key}: ${exists ? '❌ Still exists' : '✅ Deleted'}`);
}
console.log("\n🎉 Round 1 Redis state cleared successfully!");
} catch (error) {
console.error("❌ Error clearing Round 1 Redis state:", error);
} finally {
// Close Redis connection
await redis.quit();
console.log("🔐 Redis connection closed");
}
}
clearRound1RedisState();