diff --git a/packages/redis/src/index.js b/packages/redis/src/index.js index 9b5f074..f437353 100644 --- a/packages/redis/src/index.js +++ b/packages/redis/src/index.js @@ -43,16 +43,14 @@ class KeyvRedis { async clear (namespace) { const match = namespace ? `${namespace}:*` : '*' const stream = this.redis.scanStream({ match }) - const keys = [] - const collectKeys = new Transform({ + const unlinkKeys = new Transform({ objectMode: true, - transform (chunk, _, next) { - keys.push.apply(keys, chunk) + transform: async (chunk, _, next) => { + await this.redis.unlink(chunk) next() } }) - await pipeline(stream, collectKeys) - if (keys.length > 0) await this.redis.unlink(keys) + await promisify(pipeline)(stream, unlinkKeys) } async * iterator (namespace) {