小编Bor*_*aMa的帖子

如何创建第二个Rails内存存储缓存?

我正在使用Rails 5.我当前正在使用Rails内存缓存来缓存数据库查询结果,例如,这是在我的state.rb模型中...

  def self.cached_find_by_iso_and_country_id(iso, country_id)
    if iso
      Rails.cache.fetch("#{iso.strip.upcase} #{country_id}") do
        find_by_iso_and_country_id(iso.strip.upcase, country_id)
      end
    end
  end
Run Code Online (Sandbox Code Playgroud)

我的问题是,如何创建第二个内存中的Rails缓存(我需要一个用于存储我从Internet下载的文件),这不会干扰我上面的查询缓存?我不希望文件缓存中的条目导致我的查询缓存中的条目被逐出.

caching ruby-on-rails in-memory ruby-on-rails-5

11
推荐指数
1
解决办法
1578
查看次数