081_create_cache_informations.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:1k
源码类别:

Ajax

开发平台:

Others

  1. class CreateCacheInformations < ActiveRecord::Migration
  2.   def self.up
  3.     # With this migration, Old cache is useless. So we need delete all old cache
  4.     # Now what page is in cache is manage by cache_informations table
  5.     PageCache.old_sweep_all
  6.     # In commit before, cache manage by file. We delete this cache if exist.
  7.     # It's use only to all edge blog updated several time
  8.     if File.exist?(File.join(Rails.root,'path_cache'))
  9.       File.read(File.join(Rails.root,'path_cache')).split("n").each do |page_save|
  10.         FileUtils.rm File.join(PageCache.public_path, page_save)
  11.       end
  12.       FileUtils.rm_f File.join(Rails.root,'path_cache')
  13.     end
  14.     create_table :cache_informations do |t|
  15.       t.string :path
  16.       t.timestamps
  17.     end
  18.     # Add index on path because there are validates_uniqueness on it
  19.     add_index :cache_informations, :path
  20.   end
  21.   def self.down
  22.     drop_table :cache_informations
  23.   end
  24. end