From 89b4b659cf3865770f9afb6534729c3b392f3b0d Mon Sep 17 00:00:00 2001 From: didinele Date: Sat, 27 Feb 2021 10:06:21 +0200 Subject: [PATCH 1/2] chore: remove redundant methods --- libs/redis-store/src/index.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/libs/redis-store/src/index.ts b/libs/redis-store/src/index.ts index 18d7505..f705912 100644 --- a/libs/redis-store/src/index.ts +++ b/libs/redis-store/src/index.ts @@ -139,15 +139,6 @@ export class RedisStore implements IStore { return this.decode(data); } - /** - * Retrieves multiple keys from Redis using a single hmget call. - * @param keys The keys to retrieve - * @returns An array of the values - */ - public async getM(...keys: string[]) { - const data = await this.redis.hmget(this.hash, ...keys); - return data.map(e => e ? this.decode(e) : null); - } public async set(key: string, value: T) { const size = await this.redis.hlen(this.hash); @@ -162,10 +153,6 @@ export class RedisStore implements IStore { return count > 0; } - public deleteM(...keys: string[]) { - return this.redis.hdel(this.hash, ...keys); - } - public async findKey(cb: StoreSingleEntryCallback) { for await (const [key, value] of this) { if (cb(value, key)) return key; From c46228aedfcc957a91f59340e3104763d6d8dfdd Mon Sep 17 00:00:00 2001 From: didinele Date: Sat, 27 Feb 2021 10:10:45 +0200 Subject: [PATCH 2/2] chore: random qol --- libs/redis-store/src/index.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libs/redis-store/src/index.ts b/libs/redis-store/src/index.ts index f705912..ae0dcd4 100644 --- a/libs/redis-store/src/index.ts +++ b/libs/redis-store/src/index.ts @@ -139,7 +139,6 @@ export class RedisStore implements IStore { return this.decode(data); } - public async set(key: string, value: T) { const size = await this.redis.hlen(this.hash); if (this.maxSize && size >= this.maxSize) await this.empty(); @@ -207,13 +206,10 @@ export class RedisStore implements IStore { } public async map(cb: StoreMapCallback) { - const raw = await this.redis.hgetall(this.hash); - return Object - .entries(raw) - .map(([key, value]) => cb( - this.decode(value), - key - )); + const output: V[] = []; + for await (const [key, value] of this) output.push(cb(value, key)); + + return output; } public async empty(cb?: StoreSingleEntryCallback) {