Skip to content

Conversation

sastcsgh
Copy link

@sastcsgh sastcsgh commented Sep 9, 2025

Description

This PR adds an option to the client (emitInvalidate) that allows the client to emit invalidate events when it receives invalidation messages from the Redis server. This is similar to what the Client Side Cache does, except it doesn't require the cache to be enabled. This is useful when you want to perform certain transformations on the data from Redis and cache the result of these manually, while still being able to automatically receive invalidation events for the data you pull from the server.


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

@nkaradzhov
Copy link
Collaborator

Hi @sastcsgh, thanks for the PR, much appreciated! Im so sorry, we just merged a PR that touches on how you interact with the commands-queue. Those changes are in a bit of a conflict with your changes. It would be great if you fix the conflicts, then I can review more thoroughly.

Just to give you some hints:
The new way we hook to push events on the commands-queue is via addPushHandler, also take a look at the PushHandler definition. Keep in mind that currently, client-side caching is fully consuming the invalidate push message by returning true ( maybe you can make it return false, then return true from your new handler )

@sastcsgh
Copy link
Author

No worries @nkaradzhov, the new pushHandler logic looks much more robust than the old solution anyway.
I re-wrote the logic for emitInvalidate in the new push handler style. (Like before, it's basically the same logic as for the cache, except it emits the invalidate event instead of calling the invalidate method of the clientSideCache).
I left the push handler for the cache as it was, since the cache itself emits the invalidate event anyway, so when the cache is used, we can listen for the event there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants