Junior Track Roadmap

Solid Cache: database caching

This course follows how one Rails application caches with Solid Cache, a store backed by the database. It covers when caching makes sense, the six fragment caches and their multi-part keys, and how versioning on updated_at retires old entries without manual clearing. It contrasts this with a Rails.cache.fetch value that expires after five minutes. It then inspects the SolidCache::Entry table and explains why the cache moved to its own database while the queue and cable stayed in the primary one.

What you'll learn

  • ✓The four conditions a cache bets on, and what not to cache
  • ✓Why each element of a multi-part fragment cache key is there
  • ✓How cache_key and cache_version let entries retire themselves
  • ✓Caching a Ruby value with Rails.cache.fetch and expires_in
  • ✓What the SolidCache::Entry table stores and how reads are batched
  • ✓The trade-offs of moving the cache to its own database
Free preview · Lesson 1 5 min read

What this application caches, and why

A cache is a bet more than a speed trick. It bets that some work is expensive to produce, cheap to store, requested repeatedly, and acceptable when slightly out of date. All four have to hold. When one of them doesn't, caching makes the system worse in a way that's hard to see.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...