gpt4 book ai didi

ruby-on-rails - 缓存 expires_in 不工作

转载 作者:数据小太阳 更新时间:2023-10-29 08:35:33 26 4
gpt4 key购买 nike

我正在尝试像这样缓存数据:

def index
Rails.cache.fetch("someCache", expires_in: 12.hours) do
'someContent'
end
raise Rails.cache.fetch("someCache").inspect
end

一切正常(它返回 someContent),直到我删除设置值的 block (它已经设置了 12 小时,对吧?)并刷新页面:

def index
raise Rails.cache.fetch("someCache").inspect
end

返回 nil

最佳答案

Rails 5 的实际命令是:

rails dev:cache

此命令将切换激活,因此如果您再次运行它,它将禁用开发缓存。

您将阅读或这两个确认信息:

Development mode is now being cached.

Development mode is no longer being cached.

更多信息 here .

关于ruby-on-rails - 缓存 expires_in 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47065593/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com