test: clean conditional Redis keys safely
This commit is contained in:
@@ -62,11 +62,13 @@ const deleteProfileRedisKeys = async (): Promise<void> => {
|
|||||||
if (!redis) {
|
if (!redis) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for await (const key of redis.client.scanIterator({
|
for await (const keys of redis.client.scanIterator({
|
||||||
MATCH: `sammo:game:*:${profileName}:*`,
|
MATCH: `sammo:game:*:${profileName}:*`,
|
||||||
COUNT: 100,
|
COUNT: 100,
|
||||||
})) {
|
})) {
|
||||||
await redis.client.del(key);
|
if (keys.length > 0) {
|
||||||
|
await redis.client.del(keys);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -61,11 +61,13 @@ const deleteProfileRedisKeys = async (): Promise<void> => {
|
|||||||
if (!redis) {
|
if (!redis) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for await (const key of redis.client.scanIterator({
|
for await (const keys of redis.client.scanIterator({
|
||||||
MATCH: `sammo:game:*:${profileName}:*`,
|
MATCH: `sammo:game:*:${profileName}:*`,
|
||||||
COUNT: 100,
|
COUNT: 100,
|
||||||
})) {
|
})) {
|
||||||
await redis.client.del(key);
|
if (keys.length > 0) {
|
||||||
|
await redis.client.del(keys);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -155,8 +155,10 @@ delete_owned_redis_keys() {
|
|||||||
await client.connect();
|
await client.connect();
|
||||||
try {
|
try {
|
||||||
for (const pattern of patterns) {
|
for (const pattern of patterns) {
|
||||||
for await (const key of client.scanIterator({ MATCH: pattern, COUNT: 100 })) {
|
for await (const keys of client.scanIterator({ MATCH: pattern, COUNT: 100 })) {
|
||||||
await client.del(key);
|
if (keys.length > 0) {
|
||||||
|
await client.del(keys);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user