`rescue in retrieve_store_class': Could not find cache store adapter for dalli_store

646 views Asked by At

Used versions below

  • rails 5.2.8
  • ruby 2.3.1
  • dalli 3.0.4

I receive the following error:

cache.rb:110:in `rescue in retrieve_store_class': Could not find cache store adapter for dalli_store (cannot load such file -- active_support/cache/dalli_store) (RuntimeError)
def retrieve_store_class(store)
  # require_relative cannot be used here because the class might be
  # provided by another gem, like redis-activesupport for example.
  require "active_support/cache/#{store}"
rescue LoadError => e
  raise "Could not find cache store adapter for #{store} (#{e})"
else
  ActiveSupport::Cache.const_get(store.to_s.camelize)
end

Below code i have changed but same error coming.

def retrieve_store_class(store)
  # require_relative cannot be used here because the class might be
  # provided by another gem, like redis-activesupport for example.
  begin #added begin statement after getting error
    require "active_support/cache/#{store}"
  rescue LoadError => e
    raise "Could not find cache store adapter for #{store} (#{e})"
  else
    ActiveSupport::Cache.const_get(store.to_s.camelize)
  end
end
1

There are 1 answers

0
Holger Just On

It seems you have set config.cache_store = :dalli_store. This active support cache store implementation was provided by the dalli gem itself before dalli 3.0.

Since dalli 2.7.11, the cache store was deprecated however in favor of Rails' own mem_cache_store client which uses dalli internally.

With the release of dalli 3.0.0, the dalli_store (and all other rails specific code) was entirely removed from dalli.

To continue using memcache as your cache store, you should thus use Rails' own mem_cache_store.

See https://guides.rubyonrails.org/caching_with_rails.html#activesupport-cache-memcachestore and https://github.com/petergoldstein/dalli/wiki/Using-Dalli-with-Rails for details about how to use dalli with Rails.