chore: sync state and push to Gitea

Made-with: Cursor
This commit is contained in:
DBIS Core Team
2026-03-02 13:17:20 -08:00
parent 2b0404c4d6
commit 73e8d30190
9 changed files with 162 additions and 62 deletions

View File

@@ -32,10 +32,16 @@ export class CacheService {
constructor(redisClient?: RedisClient) {
if (redisClient) {
this.redis = redisClient;
} else if (this.config.enabled && process.env.REDIS_URL) {
try {
const Redis = require('ioredis');
this.redis = new Redis(process.env.REDIS_URL, { maxRetriesPerRequest: 2 }) as unknown as RedisClient;
} catch {
logger.warn('Redis (ioredis) not available - caching disabled. Install ioredis and set REDIS_URL for cache.');
this.config.enabled = false;
}
} else if (this.config.enabled) {
// TODO: Initialize Redis client
// this.redis = new Redis(process.env.REDIS_URL || 'redis://localhost:6379');
logger.warn('Redis client not initialized - caching disabled');
logger.warn('REDIS_URL not set - caching disabled');
this.config.enabled = false;
}
}
@@ -137,13 +143,21 @@ export class CacheService {
* Invalidate deal cache
*/
async invalidateDealCache(dealId: string): Promise<void> {
const patterns = [
`risk:${dealId}:*`,
`deal:${dealId}:*`,
];
// TODO: Implement pattern-based deletion if needed
logger.debug('Deal cache invalidated', { dealId });
if (!this.redis || !this.config.enabled) {
logger.debug('Deal cache invalidated (no Redis)', { dealId });
return;
}
const patterns = [`risk:${dealId}:*`, `deal:${dealId}:*`];
try {
const redis = this.redis as RedisClient & { keys?(pattern: string): Promise<string[]> };
for (const pattern of patterns) {
const keys = redis.keys ? await redis.keys(pattern) : [];
if (keys.length > 0) await Promise.all(keys.map((k) => this.redis!.del(k)));
}
logger.debug('Deal cache invalidated', { dealId });
} catch (err) {
logger.error('Cache invalidateDealCache error', { dealId, error: err });
}
}
}