From fb0b3de16e18536a578b061bfab5f53b7580b1b3 Mon Sep 17 00:00:00 2001 From: Andrew Jo Date: Thu, 5 Dec 2024 11:47:58 -0800 Subject: [PATCH] refactor: node-redis returns native promises --- src/redis.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/redis.ts b/src/redis.ts index 45a722e..f0e341a 100644 --- a/src/redis.ts +++ b/src/redis.ts @@ -3,8 +3,6 @@ * @module @verdigris/nitrous/drivers */ -import { promisify } from "util"; - import { Driver } from "@verdigris/nitrous"; import { RedisClientType, @@ -56,39 +54,39 @@ export default class Redis extends Driver { } private _ping(): Promise { - return promisify(this.client.ping).bind(this.client)(); + return this.client.ping.bind(this.client)(); } private _keys(pattern: string): Promise { - return promisify(this.client.keys).bind(this.client)(pattern); + return this.client.keys.bind(this.client)(pattern); } private _exists(...keys: string[]): Promise { - return promisify(this.client.exists).bind(this.client)(...keys); + return this.client.exists.bind(this.client)(...keys); } private _get(key: string): Promise { - return promisify(this.client.get).bind(this.client)(key); + return this.client.get.bind(this.client)(key); } private _set(key: string, value: string): Promise<"OK"> { - return promisify(this.client.set).bind(this.client)(key, value); + return this.client.set.bind(this.client)(key, value); } private _setex(key: string, seconds: number, value: string): Promise { - return promisify(this.client.setEx).bind(this.client)(key, seconds, value); + return this.client.setEx.bind(this.client)(key, seconds, value); } private _ttl(key: string): Promise { - return promisify(this.client.ttl).bind(this.client)(key); + return this.client.ttl.bind(this.client)(key); } private _expire(key: string, seconds: number): Promise { - return promisify(this.client.expire).bind(this.client)(key, seconds); + return this.client.expire.bind(this.client)(key, seconds); } private _delete(keys: string | string[]): Promise { - return promisify(this.client.del).bind(this.client)(keys); + return this.client.del.bind(this.client)(keys); } public get isClosed(): boolean { @@ -137,7 +135,7 @@ export default class Redis extends Driver { } public async close(): Promise { - const quit = promisify(this.client.quit).bind(this.client); + const quit = this.client.quit.bind(this.client); return (await quit()) === "OK"; } }