By default, Dalli has two fallbacks if no server addresses are given:
- $MEMCACHE_SERVERS
- "127.0.0.1:11211"
However, MemCacheStore does its own check for addresses, and falls back
to "localhost:11211" if none are present.
This can lead to bugs in migrations from the deprecated :dalli_store
(provided by the Dalli) to :mem_cache_store:
```diff
-config.cache_store = :dalli_store # could be implicitly relying on $MEMCACHE_SERVERS
+config.cache_store = :mem_cache_store # ignores $MEMCACHE_SERVERS
```
By removing our own fallback and simply passing `nil` to Dalli::Client,
we get its fallback logic for free. Tests are added so we can detect if
this ever changes.
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.
When using Puma or another threaded server it is useful to know about
connection pool options for the cache stores. This commit explains how
to configure and enable the connection pool in the guides.
Previously the documentation for expires_in suggested that the option
was available for all cache stores. This clarifies that the behavior can
be supported, but is not always supported.
As discussed in #33203 rails command already looks for, and runs,
bin/rails if it is present.
We were mixing recommendations within guides and USAGE guidelines,
in some files we recommended using rails, in others bin/rails and
in some cases we even had both options mixed together.
[ci skip] A regular expression was used to find a lot of missing Oxford
commas and add them. The regular expression was as follows.
", ([a-zA-Z0-9.\`:'\"]+ ){1,6}(or|and) "
Instead of providing a configuration option to set the hash function,
switch to SHA-1 for new apps and allow upgrading apps to opt in later
via `new_framework_defaults_5_2.rb`.
Compression has long been available, but opt-in and at a 16kB threshold.
It wasn't enabled by default due to CPU cost. Today it's cheap and
typical cache data is eminently compressible, such as HTML or JSON
fragments.
Compression dramatically reduces Memcached/Redis mem usage, which means
the same cache servers can store more data, which means higher hit
rates.
To disable compression, pass `compress: false` to the initializer.
* Supports vanilla Redis, hiredis, and Redis::Distributed.
* Supports Memcached-like sharding across Redises with Redis::Distributed.
* Fault tolerant. If the Redis server is unavailable, no exceptions are
raised. Cache fetches are treated as misses and writes are dropped.
* Local cache. Hot in-memory primary cache within block/middleware scope.
* `read_/write_multi` support for Redis mget/mset. Use Redis::Distributed
4.0.1+ for distributed mget support.
* `delete_matched` support for Redis KEYS globs.
Motivation:
- #29423 surfaced some confusion about how template caching works when
using partials across files with different mime types. This doc
attempts to explain how this can be accomplished.
This is a partial revert of 07402aa1307a4ff71b4ef6581f95b8612238a6af.
I also changed "cache-key" to "cache key" because "cache-key" appears
only once in the repo.
```
% git grep '\bcache-key\b' | wc -l
1
% git grep '\bcache key\b' | wc -l
28
```
Adds the "Caching in Development" section to
demonstrate usage of the dev:cache task in development mode.
Also, makes a small grammatical correction in section 2.4.
Currently mongrel is not maintained.
And it couldn't be built with any Ruby versions that
supported by Rails.
It is reasonable to remove the word "mongrel" in order to avoid
confusion from newcomer.
Code like `render(topics) => render("topics/topic")` adds confusion
for the readers. On first impression, that code feels like hash kind
of data, but it's not. So make it more clear and meaningful.