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
[ActiveSupport] [Cache] Inconsistent behavior in namespaced_key #8615
Conversation
I'm not sure what is the intended behavior, but this seems to be not backward compatible. cc @jeremy |
@rafaelfranca I did not see any doc/test indicating this is the intended behaviour. Code simply stayed as Brian wrote it 3 years ago. Maybe he can tell us more about it. cc @bdurand |
The implementation should generate unique, consistent keys for distinct objects. I'm not sure if the previous implementation was correct (it doesn't look like it is from the output listed above), but I don't think the proposed fix is correct either. Consider: id = 1 will not give the same result as id = [1] The first case will return a single User record, the second will return an array containing one User record, but both would be stored with the same cache key with the proposed fix. |
This is a whole different issue. It wasn't designed that way, was it ? The possible way that i can think of to differentiate both cases is to add a trailing slash at the end for the array with one element. |
Bump. This behavior needs to be fixed somehow... |
Any more feedback for @bbenezech core team? (cc @rafaelfranca @jeremy @bdurand) |
`cache.fetch(['foo'])` and `cache.fetch('foo')` should generate different cache keys as they are not equivalents. [related rails#8615] [related rails#8614]
👍 this is good to be merged into master... this will break backwards compatible, so it should not be backported. |
Actually, I think we are missing some tests. The tests you added are all for |
From the same note on #14269 (comment), I dont think we should go forward with this, as we cannot change the cache_key structure. |
fix for #8614
Also this is inconsistent with the (internally used) ActiveSupport::Cache.expand_cache_key