Raise exception on Cache.clear call with string argument #11904

Closed
wants to merge 1 commit into
from

Projects

None yet

3 participants

@flexoid
Contributor
flexoid commented Aug 15, 2013

Options argument from clear(options) in all bundled cache implementations
wasn't used at all, so calling clear('some_string') just flushes cache
without any warning. But this method can be easily confused with delete,
exactly what happened on my project. So I think it's better to check
if options is a hash, when it provided, and raise ArgumentError if not.

@flexoid flexoid Raise exception on Cache.clear call with string
Options argument from `clear(options)` in all bundled cache implementations
wasn't used at all, so calling `clear('some_string')` just flushes cache
without any warning. But this method can be easily confused with `delete`,
exactly what happened on my project. So I think it's better to check
if `options` is a hash, when it provided.
172b2d3
@pftg
Contributor
pftg commented Aug 15, 2013

For this PR, I think need to add Changelog

@flexoid
Contributor
flexoid commented Aug 15, 2013

Sure, I will, I just want to know first what people think about this PR.

@senny senny closed this in dd493d3 Feb 3, 2014
@senny
Member
senny commented Feb 3, 2014

I don't think code is the solution to this problem. clear is very widely used to perform a complete wipe. The docs of the method are very clear: Clear the entire cache. Be careful with this method since it could affect other processes if shared cache is being used.. And options is used throughout the Rails framework to name a Hash with symbolized keys. I pushed a small doc patch to state the fact that options is a Hash (dd493d3) but I don't think we need to add code.

@flexoid thanks for your work.

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