Speeding up Rails with Memoization
28-May-2020 1932
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 "slow work" 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.
Speeding up Rails with Memoization #ruby #rubydeveloper #rubyonrails #Speeding #Rails #Memoization https://www.rubyonrails.ba/link/speeding-up-rails-with-memoization