diff --git a/packages/redis/src/mod.ts b/packages/redis/src/mod.ts index 5774477c..2c7f4360 100644 --- a/packages/redis/src/mod.ts +++ b/packages/redis/src/mod.ts @@ -35,10 +35,11 @@ export class RedisAdapter implements StorageAdapter { } async write(key: string, value: T) { - await this.redis.set(key, JSON.stringify(value)); - if (this.ttl) { - this.redis.expire(key, this.ttl); - } + const val = JSON.stringify(value) + const ttl = this.ttl + + // ttl is undefined by default + await this.redis.set(key, val, "EX", ttl); } async delete(key: string) { @@ -58,4 +59,4 @@ const dateParser = (key: string, value: any) => { return new Date(newValue); } return value; -} \ No newline at end of file +}