From 2fac3a3cf3f6e503139fa60f1c465b0d3083534a Mon Sep 17 00:00:00 2001 From: dholms Date: Tue, 5 Dec 2023 15:49:12 -0600 Subject: [PATCH] tweaks to expiry --- packages/bsky/src/redis.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/bsky/src/redis.ts b/packages/bsky/src/redis.ts index ce9d2cecc62..ab189756054 100644 --- a/packages/bsky/src/redis.ts +++ b/packages/bsky/src/redis.ts @@ -107,9 +107,10 @@ export class Redis { async set(key: string, val: string | number, ttlMs?: number) { if (ttlMs !== undefined) { - return this.setMulti({ [key]: val }) + await this.driver.set(this.ns(key), val, 'PX', ttlMs) + } else { + await this.driver.set(this.ns(key), val) } - await this.driver.set(this.ns(key), val) } async getMulti(keys: string[]) { @@ -126,9 +127,10 @@ export class Redis { async setMulti(vals: Record, ttlMs?: number) { let builder = this.driver.multi({ pipeline: true }) for (const key of Object.keys(vals)) { - builder = builder.set(this.ns(key), vals[key]) if (ttlMs !== undefined) { - builder = builder.pexpire(key, ttlMs) + builder = builder.set(this.ns(key), vals[key], 'PX', ttlMs) + } else { + builder = builder.set(this.ns(key), vals[key]) } } await builder.exec()