PL30-413: CacheRegistry + CacheResetListener — distributed cache flush for all services#124
Open
pankti-shah-1kosmos wants to merge 5 commits into
Open
PL30-413: CacheRegistry + CacheResetListener — distributed cache flush for all services#124pankti-shah-1kosmos wants to merge 5 commits into
pankti-shah-1kosmos wants to merge 5 commits into
Conversation
…mport, consumer cleanup on partial failure, cleaner error messages
There was a problem hiding this comment.
Pull request overview
Adds a shared, helper-library implementation for distributed cache flush across 1Kosmos microservices by auto-registering node-cache instances and listening for Kafka “cache reset” signals, plus exposing a WTM cache flush hook.
Changes:
- Added
CacheRegistryto auto-register allNodeCacheinstances and provide a centralizedflushAll()(including WTM HTTP cache). - Added
CacheResetListenerKafka consumer to receive cache-reset events and triggerCacheRegistry.flushAll(). - Updated
WTMto exportflushCache()for clearing its internal response cache.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| WTM.js | Exposes flushCache() so external modules can flush WTM’s internal NodeCache. |
| CacheResetListener.js | Introduces Kafka listener logic to trigger process-wide cache flush on reset signals. |
| CacheRegistry.js | Introduces global registry + NodeCache auto-registration hook and flushAll() entrypoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ache
node-cache v5.x does not have a .init() prototype method, so the
previous patch (NodeCache.prototype.init) never fired. Instances were
never registered, causing 'O caches, 0 keys cleared' on flush.
Fix: replace the module export in require.cache with a wrapper function
that captures every new instance. All subsequent require('node-cache')
calls get the patched version.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds shared modules for distributed cache flush across all 1Kosmos microservices. Any service can achieve 100% cache flush with 3 changes (no per-file migration needed).
New Files
CacheRegistry.jsNodeCache.prototype.initat module load — everynew NodeCache()is auto-registeredrequire()per flush call)flushAll()→ clears all registered NodeCache instances + WTM HTTP response cache{ nodeCaches, totalKeys, wtmKeys }require()in each service's index.jsCacheResetListener.jsplatform_cache_resettopicHOSTNAME) — all pods flush simultaneouslyCacheRegistry.flushAll()on valid signalverifySignaturecallback — actual ECDSA logic in private service repos)WTM.js(modified)flushCache()export — clears internal HTTP response cacheSafety
Usage (per service — 3 changes)