-
Notifications
You must be signed in to change notification settings - Fork 337
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
How to clear the cache of the Rack Attack only #389
Comments
There's not an easy way to do that currently. We should add that as a new feature. |
How can I change the cache prefix for the rack attack? It should be somewhere, shouldn't it? If I change the prefix, it will solve the problem, as it will invalidate the relevant cache entries. |
Yes, changing the prefix would be kind of workaround to start with a clean state. Rack::Attack.cache.prefix = ... # default is 'rack::attack' We should at some point provide a way to clean all the data without needing to hack the cache prefix anyway. |
@ndvbd Just curious, what was your motivation for clearing the cache? Were you needing that during test cases so to achieve proper test case isolation or was that a need for you on production? |
We should consider having a Also discussed in #249 (comment). |
@grzuy Yes. You sometimes need to clean the cache, especially during tests, but also on production. It's a good thing to have. |
@ndvbd what is your context on cleaning the cache on production? It's not something I see very often, so I'm just curious |
For others that need this currently in their test suite, this is what we use in our RackAttack specific test cases: before do
Rack::Attack.enabled = true
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
end
after do
Rack::Attack.cache.store.clear
Rack::Attack.enabled = false
end Note that this makes use of the new I like the suggestion of |
Hi @javierjulio , Going through this again, I am not sure we'll have something in Rack::Attack which will avoid you having to make an extra call to clear the storage. I mean, you either:
Were you expecting something different in that regard? Thanks. |
|
How to clear the cache of the Rack Attack only? (clear state)
One way would be to simply change the cache prefix of the rack attack. How do we do that?
The text was updated successfully, but these errors were encountered: