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

View file

@ -1,6 +1,6 @@
import { getLogger } from '@stock-bot/logger'; import { getLogger } from '@stock-bot/logger';
import type { ShutdownCallback, ShutdownOptions } from './types';
import { SHUTDOWN_DEFAULTS } from './constants'; import { SHUTDOWN_DEFAULTS } from './constants';
import type { ShutdownCallback, ShutdownOptions } from './types';
interface CallbackEntry { interface CallbackEntry {
callback: ShutdownCallback; callback: ShutdownCallback;
@ -34,7 +34,7 @@ export class Shutdown {
* Register a cleanup callback * Register a cleanup callback
*/ */
onShutdown(callback: ShutdownCallback, priority: number = SHUTDOWN_DEFAULTS.MEDIUM_PRIORITY, name?: string): void { onShutdown(callback: ShutdownCallback, priority: number = SHUTDOWN_DEFAULTS.MEDIUM_PRIORITY, name?: string): void {
if (this.isShuttingDown) return; if (this.isShuttingDown) { return };
this.callbacks.push({ callback, priority, name }); this.callbacks.push({ callback, priority, name });
} }
@ -42,7 +42,7 @@ export class Shutdown {
* Initiate graceful shutdown * Initiate graceful shutdown
*/ */
async shutdown(): Promise<void> { async shutdown(): Promise<void> {
if (this.isShuttingDown) return; if (this.isShuttingDown) { return };
this.isShuttingDown = true; this.isShuttingDown = true;
@ -71,7 +71,7 @@ export class Shutdown {
} }
private setupSignalHandlers(): void { private setupSignalHandlers(): void {
if (this.signalHandlersRegistered) return; if (this.signalHandlersRegistered) { return };
const signals: NodeJS.Signals[] = ['SIGTERM', 'SIGINT']; const signals: NodeJS.Signals[] = ['SIGTERM', 'SIGINT'];