Add bulk store

This commit is contained in:
Adria Navarro 2024-03-05 16:46:33 +01:00
parent a4288a9dd3
commit 49db47e1fd
1 changed files with 13 additions and 0 deletions

View File

@ -279,6 +279,19 @@ class RedisWrapper {
}
}
async bulkStore(
data: Record<string, any>,
expirySeconds: number | null = null
) {
const client = this.getClient()
const dataToStore = Object.entries(data).reduce((acc, [key, value]) => {
acc[addDbPrefix(this._db, key)] = value
return acc
}, {} as Record<string, any>)
await client.mset(dataToStore)
}
async getTTL(key: string) {
const db = this._db
const prefixedKey = addDbPrefix(db, key)