-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make static_cache plugin better handle cases where forbid_lazy_load p…
…lugin is already loaded If the static_cache and forbid_lazy_load plugins were used together, code such as: static_cache_model[id].example_one_to_many_associations would fail with a lazy load error. This is because the static_cache cached instances forbid lazy loading because they were retrieved in a single query. You generally want that so that: static_cache_model.each{|o| o.example_one_to_many_associations} raises a lazy load error, since that is a type of N+1 (really N+0) case. Have the static cache plugin make it so that if forbid_lazy_load plugin is already loaded for the class, attempts to retrieve a single object via .[], .cache_get_pk, and .first return a frozen object copy that does not forbid lazy loading. This approach is not ncessary if the :frozen option is given to the static_cache plugin, since a copy is already created in that case.
- Loading branch information
1 parent
af953ca
commit f473b7b
Showing
3 changed files
with
133 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters