-
Notifications
You must be signed in to change notification settings - Fork 21.8k
send normalized keys to the cache backends so they do not need to man… #22215
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
Conversation
value | ||
end | ||
|
||
def decrement(name, amount = 1, options = nil) # :nodoc: | ||
value = bypass_local_cache{super} | ||
set_cache_value(value, name, amount, options) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleaning this up ... passes amount but it is not being used ...
@kaspth another one ... this did not get assigned to anyone ... |
API changes break any non-core cache store subclasses that override or call these methods. |
so leave the method as namespaced_key so nobody that calls super gets hurt ? |
And the callers of any of the methods that now require a namespaced/normalized key argument. |
Only private methods were changes, so this would only affect On Mon, Nov 9, 2015 at 8:51 PM, Jeremy Daer notifications@github.com
|
The consumers of these API are other cache store subclasses. They call or super() to these boilerplate methods. |
so they would still work fine when renamed to normalize_parameters, right ? |
I added an alias for the old method, so there should be no fallout ... good to go ? |
…age this themselves
2dbefd8
to
282be24
Compare
rebased @jeremy looking good ? |
282be24
to
f6bc5ac
Compare
@rafaelfranca got 2 cents on that ? |
@jeremy / @kaspth / @rafaelfranca ok to merge this ? |
The API is being maintained by the alias so I think it is good. Thanks |
send normalized keys to the cache backends so they do not need to man…
key = expanded_key(key) | ||
namespace = options[:namespace] if options | ||
prefix = namespace.is_a?(Proc) ? namespace.call : namespace | ||
key = "#{prefix}:#{key}" if prefix | ||
key | ||
end | ||
alias namespaced_key normalize_key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't cover backwards compatibility. The file and mem cache stores changes break user written subclasses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user written subclasses of stores, not Cache itself, right ?
Missed the conversation going on in #22205 (comment). Backing off 🤘 |
add deprecations for a smooth transition after #22215
…age this themselves
key manipulation is a recurring pattern in the cache stores (base + file + mem_cached) which makes the code less readable and mixes concerns
this moves all the key manipulation into a single method normalize_key and reuses that, which will also enable users to inherit or share logic better via modules since they no longer have to modify the key (escape_key or key_file_path or namespaced_key)