ruby `rescue in retrieve_store_class ':找不到dalli_store的缓存存储适配器

pw9qyyiw  于 2023-08-04  发布在  Ruby
关注(0)|答案(1)|浏览(101)

使用的版本如下

  • 轨道5.2.8
  • Ruby 2.3.1
  • dalli 3.0.4

我收到以下错误:

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.
  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

snz8szmq

snz8szmq1#

您似乎设置了config.cache_store = :dalli_store。这种主动支持缓存存储的实现是由dalli gem本身在dalli 3.0之前提供的。
从dalli 2.7.11开始该高速缓存存储was deprecated支持Rails自己的mem_cache_store客户端,它在内部使用dalli。
随着dalli 3.0.0的发布,dalli_store(以及所有其他特定于rails的代码)完全是removed from dalli
要继续使用memcache作为缓存存储,您应该使用Rails自己的mem_cache_store
请参阅https://guides.rubyonrails.org/caching_with_rails.html#activesupport-cache-memcachestore和https://github.com/petergoldstein/dalli/wiki/Using-Dalli-with-Rails了解如何在Rails中使用dalli的详细信息。

相关问题