You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiple models in Companybook's Rails application caches some attributes from referenced records. For instance, let's say you have a person which has one car and multiple addresses. We want to be able to read the car's color to present in the view without actually loading the car. We could have something like:
classPerson < MassiveRecord::ORM::Tablereferences_many:addressesreferences_one:car## This generates reader methods like person.car_color, which reads from a cache,# not loading up the actual car object to read color from it.#extract_and_cache:color,:from=>:car## Since addresses is representing a collection this would iterate over# all addresses-records on save and collect zip codes and cache them# so when you call person.addresses_zip_codes you'll accessing that# cached array.#extract_and_cache:zip_codes,:postal_areas,:from=>:addressesend
So, this will result in setting up some save-hooks to serialize the cache data. Also setting up some read methods to read from the cache. Good idea? Need to check if it exists a gem for delegation with cache already, even though it should not be a huge job to implement.
The text was updated successfully, but these errors were encountered:
Multiple models in Companybook's Rails application caches some attributes from referenced records. For instance, let's say you have a person which has one car and multiple addresses. We want to be able to read the car's color to present in the view without actually loading the car. We could have something like:
So, this will result in setting up some save-hooks to serialize the cache data. Also setting up some read methods to read from the cache. Good idea? Need to check if it exists a gem for delegation with cache already, even though it should not be a huge job to implement.
The text was updated successfully, but these errors were encountered: