Merged in feat/redis-fix (pull request #3209)
Feat/redis fix * feat(redis): delete multiple keys in one partition scan * fix(BOOK-603): make it possible to do multiple deletes in redis at once using one partition scan * filter out invalid keys * fix: if no valid keys are present return early * . * fix: do redis deletes after scanning through all keys * fix: do redis deletes after scanning through all keys Approved-by: Linus Flood
This commit is contained in:
committed by
Linus Flood
parent
1ecbca40a3
commit
c3381e8100
@@ -11,7 +11,7 @@ const MIN_LENGTH = 1;
|
||||
|
||||
const QUERY_TYPE = t.Object({ key: t.String({ minLength: MIN_LENGTH }) });
|
||||
const DELETEMULTIPLE_BODY_TYPE = t.Object({
|
||||
keys: t.Array(t.String({ minLength: MIN_LENGTH })),
|
||||
keys: t.Array(t.String()),
|
||||
fuzzy: t.Optional(t.Boolean({ default: false })),
|
||||
});
|
||||
|
||||
@@ -76,7 +76,10 @@ export const cacheRoutes = new Elysia({ prefix: "/cache" })
|
||||
.delete(
|
||||
"/multiple",
|
||||
async ({ body: { keys, fuzzy = false } }) => {
|
||||
const validatedKeys = keys.map(validateKey);
|
||||
const validatedKeys = keys.filter((x) => !!x).map(validateKey);
|
||||
if (validatedKeys.length === 0) {
|
||||
return { deletedKeys: 0 };
|
||||
}
|
||||
|
||||
cacheRouteLogger.debug(
|
||||
`DELETE /multiple keys=${validatedKeys.join(",")} ${fuzzy ? "(fuzzy)" : ""}`,
|
||||
|
||||
Reference in New Issue
Block a user