簡體   English   中英

在Rufus Scheduler作業中使用Rails.cache

[英]Using Rails.cache in a Rufus Scheduler job

我在計划程序作業中使用Rails.cache有麻煩。 直到我使用Rail.cache為止,才正確安排了作業並執行了模型邏輯而沒有問題。 無法通過緩存寫入或讀取任何信息; 我的寫操作不會失敗,但是當我讀取緩存時,將得到“ nil”返回。 誰能幫我找出問題所在?

config / initializers / task_scheduler.rb

scheduler = Rufus::Scheduler::singleton

scheduler.interval('10s') do

  begin
    Rails.cache.write('city', "Duckburgh")
    stats = Rails.cache.read('city')
    ApplicationController.helpers.write_log("Rufus Scheduler", "Job Completed", stats)
  end

end

我在集群模式下將Puma與Rails MemoryStore一起使用。

從Rails 4升級到Rails 5.1.2后,此問題已解決。 給定配置文件中gem和設置的更改量,我不確定這些更改中的哪一個解決了我的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM