Cra*_*lot 52 rake ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2
这两个命令是否相同?如果没有,有什么区别?
Jer*_*een 77
rake任务只清除存储在文件系统中的文件"#{Rails.root}/tmp/cache".这是该任务的代码.
namespace :cache do
# desc "Clears all files and directories in tmp/cache"
task :clear do
FileUtils.rm_rf(Dir['tmp/cache/[^.]*'])
end
end
Run Code Online (Sandbox Code Playgroud)
Rails.cache.clear将根据您的应用设置执行不同的操作config.cache_store. http://guides.rubyonrails.org/caching_with_rails.html#cache-stores
如果您正在使用config.cache_store = :file_store那么Rails.cache.clear将在功能上相同rake tmp:cache:clear.但是,如果您正在使用其他内容cache_store,例如:memory_store或:mem_cache_store,那么只会Rails.cache.clear清除您的应用缓存.在这种情况下,rake tmp:cache:clear只会尝试从中删除文件,"#{Rails.root}/tmp/cache"但可能实际上不会执行任何操作,因为文件系统上可能没有任何缓存.
| 归档时间: |
|
| 查看次数: |
56484 次 |
| 最近记录: |