From e8b573653130e6ddfc0156dcf88fc704b841804d Mon Sep 17 00:00:00 2001 From: Jonathan Hefner Date: Tue, 9 Jun 2020 02:21:45 -0500 Subject: [PATCH] Clarify ActiveSupport::Cache::NullStore behavior [ci skip] The caching guide currently indicates that values are not cached at all when using ActiveSupport::Cache::NullStore. However, values *are* cached within the scope of a single web request. This commit changes the guide to reflect that. Closes #38638. --- guides/source/caching_with_rails.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index a3b09e189a..5baeb92ff1 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -538,7 +538,7 @@ config.cache_store = :redis_cache_store, { url: cache_servers, ### ActiveSupport::Cache::NullStore -This cache store implementation is meant to be used only in development or test environments and it never stores anything. This can be very useful in development when you have code that interacts directly with `Rails.cache` but caching may interfere with being able to see the results of code changes. With this cache store, all `fetch` and `read` operations will result in a miss. +This cache store is scoped to each web request, and clears stored values at the end of a request. It is meant for use in development and test environments. It can be very useful when you have code that interacts directly with `Rails.cache` but caching interferes with seeing the results of code changes. ```ruby config.cache_store = :null_store @@ -700,6 +700,9 @@ $ bin/rails dev:cache Development mode is no longer being cached. ``` +NOTE: By default, when development mode caching is *off*, Rails uses +[`ActiveSupport::Cache::NullStore`](#activesupport-cache-nullstore). + References ----------