缓存expires_in不起作用

时间:2017-11-02 00:13:43

标签: ruby-on-rails ruby caching

我正在尝试缓存数据:

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

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

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

返回nil

2 个答案:

答案 0 :(得分:3)

Rails 5 的实际命令是:

rails dev:cache

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

您将阅读或这两个确认:

  

现在正在缓存开发模式。

     

不再缓存开发模式。

更多信息here

答案 1 :(得分:1)

解决:

要在If myCL <> "" Then For Each Cell In RngB.Cells If Cell.Value <= myBal Then r = Cell.Row If ws.Cells(r, D) <= myScore And ws.Cells(r, C) Like myCL Then myArr(x) = Cell.Row x = x + 1 End If End If Next Cell ElseIf myCL = "" Then For Each Cell In RngB.Cells If Cell.Value <= myBal Then r = Cell.Row If ws.Cells(r, D) <= myScore Then myArr(x) = Cell.Row x = x + 1 End If End If Next Cell End If For Each myRow In myArr myStr = myStr & myRow & ":" & myRow & "," Next myRow myStr = Left(myStr, Len(myStr) - 1) ws.Range(myStr).Delete 环境中启用缓存,您必须在应用程序根路径中创建development