Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀 Feature: Expose Public API to Invalidate Cache #4907

Closed
2 tasks done
Khongchai opened this issue Nov 28, 2023 · 5 comments
Closed
2 tasks done

🚀 Feature: Expose Public API to Invalidate Cache #4907

Khongchai opened this issue Nov 28, 2023 · 5 comments
Labels

Comments

@Khongchai
Copy link
Contributor

Khongchai commented Nov 28, 2023

🔖 Feature description

Every time I make changes to notification templates, I have to manually invalidate the entity cache in redis in order for the next queries to receive fresh template data. It'd be nice to have a public API that allows us to invalidate specific caches.

For now, I think this is the part that intercepts my get template detail call and return cached data

https://github.com/novuhq/novu/blob/next/apps/worker/src/app/workflow/usecases/send-message/send-message.usecase.ts#L314

🎤 Why is this feature needed ?

My use case is that we want the data to reflect immediately every time we edit a template. Right now, we have to go into redis and delete these manually:

image

✌️ How do you aim to achieve this?

PUT notification-templates/{template-id} should invalidate the entity cache.

We could, of course, invalidate the keys by interacting with redis API directly, but we don't want to shoot ourselves in the foot later when the implementation details -- the keys -- change.

Edit: I noticed that I said PUT endpoint here. That's not the case. I forgot that we were actually promoting the changes not calling the put endpoint directly because we had problems with the production, not development environment.

🔄️ Additional Information

I'm referring to the production environment. We are self-hosting. We have no use of the development environment; all of our environments, dev, staging, and prod use different databases.

Found a similar issue, but it was closed already due to inactivity.

#3520

Please let me know if there already is an existing solution or if I have missed something.

Appreciate the work y'all are doing. Thanks!

👀 Have you spent some time to check if this feature request has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

Yes I am willing to submit a PR!

@jainpawan21
Copy link
Member

@djabarovgeorge

@djabarovgeorge
Copy link
Contributor

Hi @Khongchai, appreciate you flagging this. From what I've observed, we invalidate during a PUT request. Could you provide the specific steps you take to replicate the issue, requiring the need for manual invalidation?

@Khongchai
Copy link
Contributor Author

Khongchai commented Dec 17, 2023

Hi @djabarovgeorge, thank you for the reply.

I will try to reproduce this sometime tomorrow if I am able and will get back to you. If I remember correctly, it happened to us in the production environment. We made some changes to one of the in app notification templates a development workflow and then applied the changes to prod env. I just quickly browsed the changes controller and related files and didn't see any cache invalidation there. Could it be because of this? I could be totally wrong though.

Edit: as soon as I posted this I came across the cache invalidation method in the promote change usecase for the notification template, but didn't see any for the message template change promotion.

We had to invalidate our Redis manually because the handlebars template didn't update, so could this be it?

@Cliftonz
Copy link
Contributor

Cliftonz commented Mar 1, 2024

@Khongchai Where you able to validate this?

@Khongchai
Copy link
Contributor Author

@Cliftonz Hey, sorry for the long delay. I haven't had time to go over this yet. I'll close this issue for now to unclutter your issues tab.

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

No branches or pull requests

4 participants