seperating batch payload from job queue
This commit is contained in:
parent
c57733ebca
commit
b974753d8b
5 changed files with 360 additions and 25 deletions
33
libs/cache/src/providers/hybrid-cache.ts
vendored
33
libs/cache/src/providers/hybrid-cache.ts
vendored
|
|
@ -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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue