Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Solid Cache : A Game Changer in Rails 8

Avatar for Gurzu Gurzu
August 28, 2025

Solid Cache : A Game Changer in Rails 8

Check out this insightful presentation by George Maharjan at Ruby Meetup Kathmandu!
Learn how Solid Cache enhances performance, scalability, and reliability with seamless integration in Rails 8.

Avatar for Gurzu

Gurzu

August 28, 2025
Tweet

More Decks by Gurzu

Other Decks in Programming

Transcript

  1. ❖ What is cache? ❖ Introduction to SOLID Cache ❖

    Why choose SOLID Cache? ❖ Why SOLID Cache was created? ❖ SOLID Cache vs. Redis ❖ Caching data for Api ❖ Caching strategies ❖ Solid cache Setup Demo
  2. What is cache? ➢ Caching minimizes database queries for faster

    responses. ➢ Caching boosts performance by speeding up responses and reducing server load ➢ Caching strategies in rails include page caching, fragment caching, and object caching. Caching is temporary storage that speeds up access by storing frequently accessed data in the memory(RAM).
  3. Introduction to Solid Cache Solid Cache introduces in Rails 8,

    improves Rails app performance by using NVME SSDs for disk-based caching, enabling larger caches without sacrificing very little speed. 1 Seamless Integration Works directly with Rails 8. 2 Large Cache size Accommodates large cache for longer period of time
  4. Why Choose Solid Cache? Database Backed Caching Stores cached data

    on disk instead of in memory. Seamless Integration Works out of the box. No need for extra setup. SSD-Powered Speed Leverages the speed of NVME SSDs for fast performance without memory limitations. No External Infrastructure No need for separate server.
  5. Why was SOLID Cache Created ➢ No need to manage

    a list of gem for caching solution ➢ No external dependencies ➢ Cheaper option with more benefits than tradeoffs ➢ Easy to integrate into the system ➢ Can manage large cache data
  6. Solid Cache vs. Redis Feature Solid Cache Redis Integration Built

    into Rails 8 External Service Setup Zero setup Requires setup Performance Rails Optimized High performance Data Expiry Automatic Manual Scalability Designed for large apps Needs config Reliability No cache lost on server restart Cache lost on Server restart Dependency No external Requires server
  7. Caching Data for APIs Cache API Response class Api::V1::ProductsController <

    ApplicationController def index products = Rails.cache.fetch("api_products", expires_in: 6.hours) do Product.select(:id, :name, :price).to_a end render json: { products: products } end end Solid Cache reduces redundant database queries for APIs, improving performance with cached API response data.
  8. Caching Strategies Shared Partial Caching render(partial: "hotels/hotel", collection: @hotels, cached:

    true) Faster page loads. Expire cache with Rails.cache.delete("products_list") when underlying data changes.
  9. Russian Doll caching <% cache product do %> <%= render

    product.games %> <% end %> Improves rendering speed. < % cache game do %> <%= render game %> <% end %> Nesting cache fragments inside cache fragments
  10. Low-Level Caching product_price = Rails.cache.fetch( "product_#{product.id}_price", expires_in: 1.hour) do product.calculate_discounted_price

    end Store calculations for quick access. Fragment Caching <% cache("new_product_form") do %> <%= form_with model: @product do |f| %> <%= f.text_field :name %> <%= f.number_field :price %> <%= f.submit "Save" %> <% end %> <% end %> Faster form rendering.