

Rails 7 ActiveSupport::Cache::MemCacheStore now accepts an explicit nil for addr...
source link: https://blog.saeloun.com/2021/05/11/rails-7-activesupport-cache-memcachestore-now-accepts-an-explicit-nil-for-addresses
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Rails 7 ActiveSupport::Cache::MemCacheStore now accepts an explicit nil for addresses argument
May 11, 2021 , by Prateek Choudhary1 minute read
For those using Dalli as cache store in Rails, this config should appear somewhat familiar:
config.cache_store = :dalli_cache, nil, { expires_in: 1.hour }
In the above code snippet, we passed nil
for the addresses
argument.
But if we were to migrate to :mem_cache_store
with the same config like below:
config.cache_store = :mem_cache_store, nil, { expires_in: 1.hour }
then the value of addresses
would be [nil]
instead of nil
causing an exception when trying to access the cache.
> Rails.cache.fetch('user_id')
NoMethodError: undefined method `match' for nil:NilClass
Rails 7
This PR
adds support for passing an explicit nil
to mem_cache_store
.
This change makes migrating from :dalli_store
to :mem_cache_store
easier.
After this change, below config:
config.cache_store = :mem_cache_store, nil
would be equivalent to
config.cache_store = :mem_cache_store # implicit nil for addresses
Share this post!
Recommend
-
13
Rails has added support for prepending concerns. Prepending If we prepend a module to a class, the module will be in...
-
11
New issue add ActiveSupport::Cache::RedisCacheStore#info #40929
-
11
Closed Bug 1392739 Opened 4 years ago Closed 3 years ago...
-
12
Macro std::ptr::addr_of_mut1.51.0
-
11
Macro std::ptr::addr_of1.51.0[−]...
-
9
Rails' Hidden Gems: ActiveSupport StringInquirerRails is a large framework, and it grows larger every year. This makes it easy for some helpful features to slip by unnoticed. In this series, we'll take a look at some lesser-known functionalit...
-
5
ActiveSupport has a ton of great assertions that make writing tests a joy! One such welcome change is the addition of the from option to assert_no_changes. Let’s have a look at what changed. Before ...
-
4
Rails is a large framework with a lot of handy tools built-in for specific situations. In this series, we'll take a look at some of the lesser-known tools hidden in Rails' large codebase. In this article, we'll explain the increment
-
4
Add `ptr::addr_eq` by scottmcm · Pull Request #116325 · rust-lang/rust · GitHub Skip to content...
-
9
Contributor ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK