【发布时间】:2021-12-05 13:39:01
【问题描述】:
我正在使用 Ruby3+ 和 Rails 6+ 并缓存文件:config.cache_store = :file_store, 'public/cache'
我试试:
key = 'test'
Rails.cache.write(key, 'test!!')
缓存文件工作正常:
Rails.cache.read(key)
=> "test!!"
但如果我尝试在 SO 上的其他帖子中找到的解决方案,如下所示:
Rails.cache.send(:read_entry, key, {}).expires_at
我有以下错误:
/home/USER/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/activesupport-6.1.4.1/lib/active_support/cache/strategy/local_cache.rb:131:in `read_entry': wrong number of arguments (given 2, expected 1) (ArgumentError)
如果我尝试删除最后一个参数{},则没有错误,但返回 nil ...
那么我怎样才能找到我的缓存的过期和创建日期?
【问题讨论】:
-
@razvans 我想在页面上显示缓存创建的日期(了解信息的日期);)
标签: ruby-on-rails caching