Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails 3文件存储缓存,删除过期片段_Ruby On Rails_Ruby On Rails 3_Caching - Fatal编程技术网

Ruby on rails Rails 3文件存储缓存,删除过期片段

Ruby on rails Rails 3文件存储缓存,删除过期片段,ruby-on-rails,ruby-on-rails-3,caching,Ruby On Rails,Ruby On Rails 3,Caching,我有一个在Unicorn上运行的Rails 3.2.11应用程序,它被设置为将文件存储缓存到项目外部的特定文件夹。 我还使用gem自动过期。 在某个页面中,我在不设置时间过期的情况下进行片段缓存 当一个片段过期时,我会看到在缓存文件夹中创建的新片段,但我也会看到过期的片段。缓存管理机制如何在不手动执行的情况下将其从缓存文件夹中删除?如果未将其删除,则缓存文件夹将充满未使用的垃圾、过期碎片。您可以尝试使用此功能删除所有过期碎片。您可以设置一个脚本来定期运行此命令。您可以使用它来终止片段缓存 请参见

我有一个在Unicorn上运行的Rails 3.2.11应用程序,它被设置为将文件存储缓存到项目外部的特定文件夹。 我还使用gem自动过期。 在某个页面中,我在不设置时间过期的情况下进行片段缓存

当一个片段过期时,我会看到在缓存文件夹中创建的新片段,但我也会看到过期的片段。缓存管理机制如何在不手动执行的情况下将其从缓存文件夹中删除?如果未将其删除,则缓存文件夹将充满未使用的垃圾、过期碎片。

您可以尝试使用此功能删除所有过期碎片。您可以设置一个脚本来定期运行此命令。

您可以使用它来终止片段缓存

请参见以下示例:

class ProductSweeper < ActionController::Caching::Sweeper
  observe Product

  #expire fragment after model update
  def after_save
   expire_fragment('all_available_products')   
  end

  #expire different cache after controller method modifying state is called.
  def after_products_update_some_state
    expire_action(:controller => 'products', :action => 'index') 
  end

  #can also use before:
  def before_products_update_some_state
    #do something before. 
  end
end
class ProductSweeper'products',:action=>'index')
结束
#也可以在以下情况之前使用:
def在产品更新某些状态之前
#做点什么之前。
结束
结束

这也有助于您

您必须使用
expire\u fragment
let cache(posts,current\u user)显式地执行此操作。我们如何为所有posts集合、当前用户和视图版本的所有组合获取所有片段的所有缓存键?不,我们可以
t。对于片段(产品),我们有摘要,当我们想在产品更新后使片段过期时,我们不知道这个摘要