Before 5.2 it was not possible
to write multiple entries to cache store in one shot
cache stores like
MSET command to set multiple keys in a single atomic operation.
However we were not able to use this feature of Redis
because of the way Rails had implemented caching.
Rails has implemented caching using an abstract class
which defines the interface
that all cache store classes should implement.
Rails also provides few common functionality that all cache store classes will need.
Prior to Rails 5.2
didn't have any method to set multiple entities at once.
In Rails 5.2,
write_multi was added .
Each cache store can implement this method
and provide the functionality to add multiple entries at once.
If cache store does not implement this method,
then the default implementation is
to loop over each key value pair
and sets it individually using
Multiple entities can be set as shown here.
1Rails.cache.write_multi name: 'Alan Turning', country: 'England'
gem provides redis as cache store.
However it does not implement
if we are using Rails 5.2, then there is no point in using
as Rails 5.2 comes with built in support for
redis cache store, which implements
It was added by this PR.
We need to make following change.
1# before 2config.cache_store = :redis_store 3 4# after 5config.cache_store = :redis_cache_store
redis-rails repo has a
to notify users
that development of this gem is ceased.
So it's better to use redis cache store that comes with Rails 5.2.