Feat(): distributed caching (#13435)

RESOLVES CORE-1153

**What**
- This pr mainly lay the foundation the caching layer. It comes with a modules (built in memory cache) and a redis provider.
- Apply caching to few touch point to test

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
Adrien de Peretti
2025-09-30 16:19:06 +00:00
committed by GitHub
co-authored by Carlos R. L. Rodrigues
parent 5b135a41fe
commit b9d6f73320
117 changed files with 5741 additions and 530 deletions
@@ -158,6 +158,10 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
const promises: Promise<unknown>[] = []
if (eventsToEmit.length) {
eventsToEmit.map((eventData) =>
this.callInterceptors(eventData, { isGrouped: false })
)
const emitData = this.buildEvents(eventsToEmit, options)
promises.push(this.queue_.addBulk(emitData))
@@ -213,6 +217,21 @@ export default class RedisEventBusService extends AbstractEventBusModuleService
async releaseGroupedEvents(eventGroupId: string) {
const groupedEvents = await this.getGroupedEvents(eventGroupId)
// Call interceptors before emitting grouped events
// Extract the original messages from the job data structure
groupedEvents.map((jobData) => {
// Reconstruct the message from the job data
const message = {
name: jobData.name,
data: jobData.data,
metadata: jobData.data.metadata,
}
this.callInterceptors(message as any, {
isGrouped: true,
eventGroupId,
})
})
await this.queue_.addBulk(groupedEvents)
await this.clearGroupedEvents(eventGroupId)