seperating batch payload from job queue

This commit is contained in:
Boki 2025-06-10 09:58:20 -04:00
parent c57733ebca
commit b974753d8b
5 changed files with 360 additions and 25 deletions

View file

@ -258,4 +258,37 @@ export class HybridCache implements CacheProvider {
await this.redisCache.disconnect();
this.logger.info('Hybrid cache disconnected');
}
async waitForReady(timeout: number = 5000): Promise<void> {
// Memory cache is always ready, only need to wait for Redis
await this.redisCache.waitForReady(timeout);
}
isReady(): boolean {
// Memory cache is always ready, check Redis status
return this.memoryCache.isReady() && this.redisCache.isReady();
}
/**
* Manually trigger a refresh of the Redis cache for a specific key
* Useful for updating the cache after a data change
*/
async refresh(key: string): Promise<void> {
try {
// Get the current value from memory (L1)
const currentValue = await this.memoryCache.get(key);
if (currentValue !== null) {
// If exists in memory, update Redis (L2)
await this.redisCache.set(key, currentValue);
this.logger.info('Cache refresh (L2)', { key });
} else {
this.logger.debug('Cache refresh skipped, key not found in L1', { key });
}
} catch (error) {
this.logger.error('Cache refresh error', {
key,
error: error instanceof Error ? error.message : String(error)
});
}
}
}