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

add decorator to clear cache #111

Open
M4R1KU opened this issue Aug 6, 2018 · 2 comments
Open

add decorator to clear cache #111

M4R1KU opened this issue Aug 6, 2018 · 2 comments

Comments

@M4R1KU
Copy link

M4R1KU commented Aug 6, 2018

I'm submitting a ... (check one with "x")

[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Support request
[x] Feature request
[ ] Documentation issue or request

Current behavior
When using the Decorators you are not able to clear the cache or remove a certain key from the cache unless you do it manually by injecting the CacheService.

Expected/desired behavior
I expect to have the possibilty to clear the cache via decorator the same way you can add items by calling a method.
The new decorator would need the key of the cache which one wants to purge and also the @Cachekey should work with the new decorator.

I thought about something like the CacheEvict Annotation in the Spring Framework https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/cache/annotation/CacheEvict.html

What is the motivation / use case for changing the behavior?
The motivation is to not have to inject the CacheService when wanting to clear the cache. An example of a situation where this could be desirable is when you cache a list of an Object of type X and when the user makes a change to this list for instance adding and element or removing one you want to get the new data from the server on the next call instead of having the old value returned.

Environment

  • Angular version: 6.x.x

  • Browser:
    Browser independent

  • For Tooling issues:
    irrelevant

  • Others:
    I would be pleased by an answer and some feedback on the idea. 😄

@angelnikolov
Copy link

angelnikolov commented Sep 4, 2018

Feedback:
This might be similar to the CacheBuster decorator of ngx-cacheable
https://github.com/angelnikolov/ngx-cacheable/blob/master/cache-buster.decorator.ts
I.e - just use an arbitrary Subject - subscribe to it from all cache points and emit any value through it when you want to cache bust all subscribers.

@fulls1z3 fulls1z3 changed the title Add Decorator for clearing cache add decorator to clear cache Dec 24, 2018
@fulls1z3
Copy link
Owner

@M4R1KU @angelnikolov sorry for the delay, had busy times. feel free to fire a PR and i'll approve.

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

No branches or pull requests

3 participants