fixed lint

This commit is contained in:
Boki 2025-06-26 15:44:52 -04:00
parent 885b484a37
commit 8680b6ec20
2 changed files with 15 additions and 9 deletions

View file

@ -1,7 +1,7 @@
import Redis from 'ioredis';
import { RedisConnectionManager } from './connection-manager';
import type { CacheOptions, CacheProvider, CacheStats } from './types';
import { CACHE_DEFAULTS } from './constants';
import type { CacheOptions, CacheProvider, CacheStats } from './types';
/**
* Simplified Redis-based cache provider
@ -88,17 +88,23 @@ export class RedisCache implements CacheProvider {
let oldValue: T | null = null;
if (opts.getOldValue) {
const existing = await this.redis.get(fullKey);
if (existing) oldValue = JSON.parse(existing);
if (existing) {
oldValue = JSON.parse(existing);
}
}
const ttl = opts.ttl ?? this.defaultTTL;
if (opts.onlyIfExists) {
const result = await this.redis.set(fullKey, serialized, 'EX', ttl, 'XX');
if (!result) return oldValue;
if (!result) {
return oldValue;
}
} else if (opts.onlyIfNotExists) {
const result = await this.redis.set(fullKey, serialized, 'EX', ttl, 'NX');
if (!result) return oldValue;
if (!result) {
return oldValue;
}
} else if (opts.preserveTTL) {
const currentTTL = await this.redis.ttl(fullKey);
if (currentTTL > 0) {
@ -200,7 +206,7 @@ export class RedisCache implements CacheProvider {
}
async waitForReady(timeout = 5000): Promise<void> {
if (this.redis.status === 'ready') return;
if (this.redis.status === 'ready') {return;}
return new Promise((resolve, reject) => {
const timer = setTimeout(() => {