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 the ability to reset a cache to an initial state #26

Closed
whitfin opened this issue May 17, 2016 · 0 comments · Fixed by #29
Closed

Add the ability to reset a cache to an initial state #26

whitfin opened this issue May 17, 2016 · 0 comments · Fixed by #29
Assignees

Comments

@whitfin
Copy link
Owner

whitfin commented May 17, 2016

I have recently hit a use case where it would be nice to have an option to reset a cache, e.g. Cachex.reset/2.

Reset would re-initalize all hooks and empty the cache

I'm thinking of three options:

  • async: the default option which casts instead of calling
  • only: a list of things to reset, e.g. [ :cache, :hooks ]
    • so only: :hooks would reset hook states but not the cache itself
  • hooks: a list of hooks to reset, if you wish to only reset certain hooks.

Here are a couple of examples:

Cachex.reset(:my_cache) # wipes cache, resets all hooks
Cachex.reset(:my_cache, only: :hooks) # only resets the hooks of a cache, leaves it filled
Cachex.reset(:my_cache, hooks: [ Cachex.Stats ]) # only resets the stats hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant