<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Caching - Tag - MC Squared</title><link>https://mc-squared.dev/tags/caching/</link><description>Caching - Tag - MC Squared</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.</copyright><lastBuildDate>Wed, 05 May 2021 08:59:20 +1200</lastBuildDate><atom:link href="https://mc-squared.dev/tags/caching/" rel="self" type="application/rss+xml"/><item><title>HTTP Caching in Ruby on Rails Applications</title><link>https://mc-squared.dev/2021/05/http-caching-in-ruby-on-rails-applications/</link><pubDate>Wed, 05 May 2021 08:59:20 +1200</pubDate><author>Jonathan Miles</author><guid>https://mc-squared.dev/2021/05/http-caching-in-ruby-on-rails-applications/</guid><description>&lt;p>A general way to describe caching is storing some data so that we can quickly retrieve it later. Sometimes, this means storing computed data so that it does not need to be re-computed, but it can also refer to storing data locally to avoid having to fetch it again. Your computer does this constantly, as your operating system tries to keep frequently accessed data in RAM so that it doesn&amp;rsquo;t have to be fetched again from a hard drive or SSD.&lt;/p></description></item><item><title>How ActiveRecord Uses Caching To Avoid Unnecessary Trips To The Database</title><link>https://mc-squared.dev/2021/02/how-active-record-caches-by-default-in-ruby-on-rails/</link><pubDate>Sat, 20 Feb 2021 08:59:20 +1200</pubDate><author>Jonathan Miles</author><guid>https://mc-squared.dev/2021/02/how-active-record-caches-by-default-in-ruby-on-rails/</guid><description>&lt;p>A general way to describe caching is storing the result of some code so that we can quickly retrieve it later. In some cases, this means storing a computed value to avoid needing to recompute it later. However, we can also cache data by simply keeping it in memory, without performing any computations, to avoid having to read from a hard drive or perform a network request.&lt;/p>
&lt;p>This latter form is particularly relevant for ActiveRecord, where the database often runs on a separate server. Thus, all requests incur network-traffic overhead, not to mention the load placed on the database server when the query is performed again.&lt;/p></description></item><item><title>Using Low-Level Caching in Ruby on Rails Applications</title><link>https://mc-squared.dev/2020/10/using-low-level-caching-in-ruby-on-rails-applications/</link><pubDate>Thu, 01 Oct 2020 08:59:20 +1200</pubDate><author>Jonathan Miles</author><guid>https://mc-squared.dev/2020/10/using-low-level-caching-in-ruby-on-rails-applications/</guid><description>&lt;h2 id="types-of-caching">Types of Caching&lt;/h2>
&lt;p>Caching is a general term which means storing the result of some code so that we can quickly retrieve it later. This allows us to, for example, perform some heavy number-crunching once and then just re-use the value without having to recalculate it again. Although the general concept is the same for all types of caching, there are various mechanisms we can use depending on what we are trying to cache.&lt;/p></description></item><item><title>Using Memoization To Improve Your Ruby on Rails Application's Performance</title><link>https://mc-squared.dev/2020/06/using-memoization-in-ruby-on-rails-applications/</link><pubDate>Sat, 20 Jun 2020 08:59:20 +1200</pubDate><author>Jonathan Miles</author><guid>https://mc-squared.dev/2020/06/using-memoization-in-ruby-on-rails-applications/</guid><description><![CDATA[<h2 id="what-is-memoization">What is Memoization?</h2>
<p>When developing applications we often have methods that run slowly. Perhaps they need to query the database, or hit an external service, both of which can cause them to slow down. We could call the method every time we need that data and just accept the overhead, but if performance is a concern we have some options. For one, we can assign the data to a variable and re-use it, which would speed up the process. While a possible solution, manually managing that variable could quickly become tedious. But, what if instead, the method doing this &ldquo;slow work&rdquo; could just handle that variable for us? This would allow us to call the method in the same way, but have the method save and re-use the data. This is exactly what memoization does.</p>]]></description></item></channel></rss>