【发布时间】:2023-03-16 11:00:01
【问题描述】:
我有一个在 Debian buster 上运行的 Rails 6 应用程序。在一个地方,我正在使用“低级”缓存。以下是相关代码:
# Get the value.
def self.ae_enabled?()
Rails.cache.fetch("ae_enabled", expires_in: 1.hour)
end
# Change the value.
def self.ae_toggle()
ac = AdminConfiguration.find_by(name: "ae-enabled")
ac.value = ! ac.value
ac.save()
# Invalidate the cache.
Rails.cache.delete("ae_enabled")
return ac
end
这工作得很好......一段时间。在某些时候,由于我无法弄清楚的原因,缓存上述值的缓存目录tmp/cache/3F1/ 将所有权从www-data:www-data(运行Apache 的用户)更改为root:root。一旦发生这种情况,Apache 将无法再读取此缓存值并且应用程序将引发错误。
奇怪的是,tmp/cache/ 下的其他目录没有权限发生变化,只是与这个低级缓存关联的一个。
为什么那个特定的缓存目录会改变所有权?
技术细节:Rails 版本 6.0.3.3。
【问题讨论】:
标签: ruby-on-rails caching file-ownership