<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/github---igorkasyanchuk-rails-named-cache-multiple-named-cache-stores-for-rails-through-rails-cach-b8mzdnstp" -->

---
title: GitHub - igorkasyanchuk/rails_named_cache: Multiple...
description: rails_named_cache is a Ruby gem that adds multiple named cache stores to Rails via `Rails.cache(:name)`. It lets you configure distinct cache backends...
canonical: https://daily.dev/posts/github---igorkasyanchuk-rails-named-cache-multiple-named-cache-stores-for-rails-through-rails-cach-b8mzdnstp
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: GitHub - igorkasyanchuk/rails_named_cache: Multiple named cache stores for Rails, through Rails.cache(:name) | daily.dev
og:description: rails_named_cache is a Ruby gem that adds multiple named cache stores to Rails via `Rails.cache(:name)`. It lets you configure distinct cache backends...
og:url: https://daily.dev/posts/github---igorkasyanchuk-rails-named-cache-multiple-named-cache-stores-for-rails-through-rails-cach-b8mzdnstp
og:image: https://api.daily.dev/og/posts/b8mzDnstP.png
og:image:alt: GitHub - igorkasyanchuk/rails_named_cache: Multiple named cache stores for Rails, through Rails.cache(:name)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub - igorkasyanchuk/rails_named_cache: Multiple named cache stores for Rails, through Rails.cache(:name)

**[Ruby Flow](https://daily.dev/sources/rubyflow)** · 12 min read · 1 upvotes · 0 comments

## Summary

rails_named_cache is a Ruby gem that adds multiple named cache stores to Rails via `Rails.cache(:name)`. It lets you configure distinct cache backends (MemoryStore, Redis, FileStore, NullStore) per domain, each with its own size, TTL, and eviction policy. Named stores are isolated — clearing one doesn't affect others — and the API returns the raw ActiveSupport store with no wrapper. The gem covers L1/L2 layering patterns, per-store expiration, hit/miss logging, testing strategies (clearing between examples, swapping stores per test), and important caveats around memory usage, thread contention, cross-process invalidation, and Redis keyspace isolation via namespaces.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://github.com/igorkasyanchuk/rails_named_cache>

## Questions this post answers

### How do I use multiple different cache stores in a single Rails application?

The rails_named_cache gem lets you configure multiple named ActiveSupport::Cache::Store instances through config.named_cache_stores, then access each with Rails.cache(:name), such as Rails.cache(:memory) or Rails.cache(:redis). The default Rails.cache remains untouched, and unknown names raise an UnknownStoreError instead of silently falling back.

_Developers designing multi-tier caching in Rails can track gem updates like this on daily.dev._

### Why is ActiveSupport::Cache::MemoryStore so much faster than Redis for reads in Rails?

MemoryStore reads avoid a network round trip, connection pool checkout, and wire protocol encode/decode that Redis or Memcached require. Benchmarked on Ruby 3.4.5 on Apple silicon reading a small hash 200,000 times, MemoryStore achieved 362,918 reads/sec (2.8 µs/read) versus FileStore's 51,202 reads/sec (19.5 µs/read); Redis adds a socket round trip on top of similar bookkeeping.

_Anyone tuning Rails cache performance can follow benchmarking write-ups like this on daily.dev._

### Why does clearing a Redis cache store wipe my entire Redis database in Rails?

A RedisCacheStore with no namespace implements clear as FLUSHDB, which empties the whole Redis database rather than just that store's keys, potentially wiping other stores, Sidekiq queues, or a colleague's development data. Setting a namespace: option on each RedisCacheStore isolates its keys so clear only deletes that store's own entries.

_Rails developers debugging cache isolation issues can find practical fixes like this on daily.dev._

## Similar posts on daily.dev

- [Rails 8 Solid Cache: Database-Backed Cache Store](https://daily.dev/posts/rails-8-solid-cache-database-backed-cache-store-6lgeokcjo) · Saeloun · 0 upvotes · 0 comments
- [Russian Doll Caching at the Edge](https://daily.dev/posts/russian-doll-caching-at-the-edge-6xbqzsvna) · Atomic Spin · 0 upvotes · 0 comments
- [GitHub - nicolasva/solid-redis](https://daily.dev/posts/github---nicolasva-solid-redis-oosnxofle) · Ruby Flow · 0 upvotes · 0 comments
- [JSON schema cache, herb:check, and more\!](https://daily.dev/posts/json-schema-cache-herb-check-and-more--tyihj9oqu) · Rails · 1 upvotes · 0 comments
- [Adding multi-tenancy to a DDD Rails app](https://daily.dev/posts/adding-multi-tenancy-to-a-ddd-rails-app-cqm2w83zd) · arkency · 0 upvotes · 0 comments

---

Tags: [#ruby](https://daily.dev/tags/ruby), [#rails](https://daily.dev/tags/rails), [#redis](https://daily.dev/tags/redis)

[View this post on daily.dev](https://daily.dev/posts/github---igorkasyanchuk-rails-named-cache-multiple-named-cache-stores-for-rails-through-rails-cach-b8mzdnstp)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"GitHub - igorkasyanchuk/rails_named_cache: Multiple named cache stores for Rails, through Rails.cache(:name)","url":"https://daily.dev/posts/github---igorkasyanchuk-rails-named-cache-multiple-named-cache-stores-for-rails-through-rails-cach-b8mzdnstp","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/github---igorkasyanchuk-rails-named-cache-multiple-named-cache-stores-for-rails-through-rails-cach-b8mzdnstp"},"datePublished":"2026-08-02T21:22:59.627Z","dateModified":"2026-09-14T07:03:45.651Z","description":"rails_named_cache is a Ruby gem that adds multiple named cache stores to Rails via `Rails.cache(:name)`. It lets you configure distinct cache backends...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/db1147dfaffc3be1d861befce51f4474?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/db1147dfaffc3be1d861befce51f4474?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Ruby Flow","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Ruby Flow","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/a21aaa8bcbbf448193a016895c90a0e1","url":"https://daily.dev/sources/rubyflow"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/github---igorkasyanchuk-rails-named-cache-multiple-named-cache-stores-for-rails-through-rails-cach-b8mzdnstp","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ruby,rails,redis","timeRequired":"PT12M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Ruby Flow","item":"https://daily.dev/sources/rubyflow"},{"@type":"ListItem","position":3,"name":"GitHub - igorkasyanchuk/rails_named_cache: Multiple named cache stores for Rails, through Rails.cache(:name)"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/github---igorkasyanchuk-rails-named-cache-multiple-named-cache-stores-for-rails-through-rails-cach-b8mzdnstp#faq","mainEntity":[{"@type":"Question","name":"How do I use multiple different cache stores in a single Rails application?","acceptedAnswer":{"@type":"Answer","text":"The rails_named_cache gem lets you configure multiple named ActiveSupport::Cache::Store instances through config.named_cache_stores, then access each with Rails.cache(:name), such as Rails.cache(:memory) or Rails.cache(:redis). The default Rails.cache remains untouched, and unknown names raise an UnknownStoreError instead of silently falling back. Developers designing multi-tier caching in Rails can track gem updates like this on daily.dev."}},{"@type":"Question","name":"Why is ActiveSupport::Cache::MemoryStore so much faster than Redis for reads in Rails?","acceptedAnswer":{"@type":"Answer","text":"MemoryStore reads avoid a network round trip, connection pool checkout, and wire protocol encode/decode that Redis or Memcached require. Benchmarked on Ruby 3.4.5 on Apple silicon reading a small hash 200,000 times, MemoryStore achieved 362,918 reads/sec (2.8 µs/read) versus FileStore's 51,202 reads/sec (19.5 µs/read); Redis adds a socket round trip on top of similar bookkeeping. Anyone tuning Rails cache performance can follow benchmarking write-ups like this on daily.dev."}},{"@type":"Question","name":"Why does clearing a Redis cache store wipe my entire Redis database in Rails?","acceptedAnswer":{"@type":"Answer","text":"A RedisCacheStore with no namespace implements clear as FLUSHDB, which empties the whole Redis database rather than just that store's keys, potentially wiping other stores, Sidekiq queues, or a colleague's development data. Setting a namespace: option on each RedisCacheStore isolates its keys so clear only deletes that store's own entries. Rails developers debugging cache isolation issues can find practical fixes like this on daily.dev."}}]}
```

