Merged in feat/redis-fix (pull request #3207)
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 Approved-by: Linus Flood
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { cacheLogger } from "../../logger"
|
||||
import { cacheMap } from "./cacheMap"
|
||||
|
||||
export async function deleteKeys(keys: string[], opts?: { fuzzy?: boolean }) {
|
||||
cacheLogger.debug("Deleting keys", keys)
|
||||
keys.forEach((key) => {
|
||||
if (opts?.fuzzy) {
|
||||
cacheMap.forEach((_, k) => {
|
||||
if (k.includes(key)) {
|
||||
cacheMap.delete(k)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
cacheMap.delete(key)
|
||||
})
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
import { cacheOrGet } from "./cacheOrGet"
|
||||
import { deleteKey } from "./deleteKey"
|
||||
import { deleteKeys } from "./deleteKeys"
|
||||
import { get } from "./get"
|
||||
import { set } from "./set"
|
||||
|
||||
import type { DataCache } from "../../Cache"
|
||||
|
||||
export async function createInMemoryCache(): Promise<DataCache> {
|
||||
return { type: "in-memory", cacheOrGet, deleteKey, get, set }
|
||||
return { type: "in-memory", cacheOrGet, deleteKey, get, set, deleteKeys }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user