Module: Vhost::RadiantCacheExtensions::MetaStore

Defined in:
lib/vhost/radiant_cache_extensions.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/vhost/radiant_cache_extensions.rb', line 27

def self.included(base)
  base.class_eval {
    def initialize(root="#{Rails.root}/tmp/cache/meta")
      super
      Radiant::Cache.meta_stores << self
    end
  
    def clear(host_and_url = nil)
      if host_and_url.nil?
        Dir[File.join(self.root, "*")].each {|file| FileUtils.rm_rf(file) }
      else
        FileUtils.rm_rf(key_path("#{host_and_url}"))
      end
    end
  
    # cache_key should, by default, include the host as well the query string
    # def cache_key(request)
    #   "#{request.host}#{request.path_info}"
    # end
  }
end