Certain slow or frequently running queries or processing are cached from the classes defining them. The Workarea system follows the Rails convention in how this is handled.
def self.cache Rails.cache.fetch('shipping_services_cache', expires_in: Workarea.config.cache_expirations.shipping_services) do Shipping::Service.all.to_a end end
The work to be cached is placed inside a call to the
Rails.cache. Like the fragment caching in the views, if the cache store does not have a fresh cache, the block is executed and the result is cached.
Resources on Low-Level Caching
How'd We Do?
If you found this article was missing information or wasn't quite what you were looking for, we are open to any suggestions or feedback on what we could do better.Help Us Out