feathers-hooks-rediscache
feathers-hooks-rediscache copied to clipboard
Add option to invalid cache in hooks
Hi, Thanks for the great work. Is it possible to invalidate the cache using the function in this package? Ideally what I wanted to do is when the user made a CRUD request that is not a find request. I want to invalidate the cache in the after hook. Thanks for your help.
What kind of option do you imagine?
That would be an "after hook" that would clean the cache upon a successful request right? Let's say a user, updates its data and you would like to clean users/<userid>
In applications I worked for, I have found easy to call the routes after I received a successful response from the API, I would the clear the key from the cache.
I can of course understand why you would want it automatised at the level of the API. I am not sure I see yet how to generalise this.
I think that indeed a hook should be made available in order to be able not to call api each time. For example an after edit/add/remove should invalidate cache for the listed elements.
Imagine a simple scenario:
- You display a list of books
- You go on detail of one book and change the title
- Back to the list should trigger a new list load with updated title