Add bulk delete

This commit is contained in:
Adria Navarro 2024-03-07 00:25:12 +01:00
parent 81af85eae0
commit d06f9e0a1c
1 changed files with 5 additions and 0 deletions

View File

@ -327,6 +327,11 @@ class RedisWrapper {
await this.getClient().del(addDbPrefix(db, key)) await this.getClient().del(addDbPrefix(db, key))
} }
async bulkDelete(keys: string[]) {
const db = this._db
await this.getClient().del(keys.map(key => addDbPrefix(db, key)))
}
async clear() { async clear() {
let items = await this.scan() let items = await this.scan()
await Promise.all(items.map((obj: any) => this.delete(obj.key))) await Promise.all(items.map((obj: any) => this.delete(obj.key)))