0

When I start rails server locally (rails 5.2.0, ruby 2.5.1) with this configuration in develompent.rb

config.action_controller.perform_caching = true  
config.cache_store = :redis_cache_storage

with gem redis '4.0.1' installed

I've this error:

Traceback (most recent call last)

.rvm/gems/ruby-2.5.1@rails-test/gems/activesupport-5.2.0/lib/active_support/cache.rb:109:in `rescue in retrieve_store_class': Could not find cache store adapter for redis_cache_storage (cannot load such file -- active_support/cache/redis_cache_storage) (RuntimeError)

any ideas?

Ruturaj Bisure
  • 151
  • 1
  • 13
David71
  • 51
  • 3

1 Answers1

0

I'm not sure where you got :redis_cache_storage but that isn't going to work because it's not part of Rails; Rails doesn't include code to use Redis as a cache out-of-the-box. You need to use the redis-rails gem to use Redis as a cache for Rails:

Add this to your Gemfile:

gem 'redis-rails'

Then add this to your config:

# config/application.rb
config.cache_store = :redis_store, "redis://localhost:6379/0/cache", { expires_in: 90.minutes }

More information and options for configuring the gem can be found at https://github.com/redis-store/redis-rails.

anothermh
  • 9,815
  • 3
  • 33
  • 52
  • Not sure about redis_cache_storage but the Rails doc mentions redis_cache_store here: https://guides.rubyonrails.org/caching_with_rails.html#activesupport-cache-rediscachestore – Jonathon Horsman Oct 29 '20 at 16:30
  • Good point. Still not built-in to Rails by default, as it requires the addition of an external dependency, but you're right! – anothermh Oct 29 '20 at 16:39
  • I think it is included in Rails 5.2 now - if you check the redis-rails gem on Github (https://github.com/redis-store/redis-rails) they say: "A quick note about Rails 5.2 Rails 5.2.0 includes a Redis cache store out of the box" – Jonathon Horsman Oct 30 '20 at 17:26
  • When I say not built in I mean that [you have to add the redis gem](https://github.com/jeremy/rails/blob/31f51b3def9ce7f9f7ec392b76943e4ac8ad0cfb/activesupport/lib/active_support/cache/redis_cache_store.rb#L8) to make it work. – anothermh Oct 30 '20 at 21:22