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

Refactor Relation#cache_key is moved from CollectionCacheKey#collection_cache_key #35848

Merged
merged 1 commit into from Apr 4, 2019

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Apr 4, 2019

The implementation of Relation#cache_key depends on some internal
relation methods (e.g. apply_join_dependency, build_subquery), but
somehow that implementation exists on the model class
(collection_cache_key), it sometimes bothers to me.

This refactors that implementation moves to Relation#cache_key, then
we can avoid send to call internal methods.

@@ -314,7 +314,50 @@ def many?
# overriding ActiveRecord::Base#collection_cache_key.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... I've realized the doc now...

You can customize the strategy to generate the key on a per model basis overriding ActiveRecord::Base#collection_cache_key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to just keep the expectation for now.

…ction_cache_key`

The implementation of `Relation#cache_key` depends on some internal
relation methods (e.g. `apply_join_dependency`, `build_subquery`), but
somehow that implementation exists on the model class
(`collection_cache_key`), it sometimes bothers to me.

This refactors that implementation moves to `Relation#cache_key`, then
we can avoid `send` to call internal methods.
@kamipo kamipo force-pushed the refactor_collection_cache_key branch from 6b96d9c to 10919bf Compare April 4, 2019 04:20
@kamipo kamipo merged commit 39d42db into rails:master Apr 4, 2019
@kamipo kamipo deleted the refactor_collection_cache_key branch April 4, 2019 04:54
kamipo added a commit that referenced this pull request Apr 19, 2019
The `collection_cache_key` is private API for a long time, but I've
maintained it in #35848 since it is mentioned in the doc
(#35848 (comment)).

The doc has removed at 1da9a7e, so there is no longer a reason to
maintain that private API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants