feathers-hooks-rediscache icon indicating copy to clipboard operation
feathers-hooks-rediscache copied to clipboard

Add option to invalid cache in hooks

Open jk1z opened this issue 5 years ago • 2 comments

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.

jk1z avatar Oct 28 '18 23:10 jk1z

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.

idealley avatar Dec 27 '18 17:12 idealley

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

blackholegalaxy avatar Jan 02 '19 12:01 blackholegalaxy