Sha256: 32a58dbd70abad9c6173f809b4c4b29ed714aeab7144beb2a80f0095d5b28eda

Contents?: true

Size: 919 Bytes

Versions: 1

Compression:

Stored size: 919 Bytes

Contents

require 'rack/cache'
require 'fileutils'

module Radiant
  module Cache
    def self.new(backend, options = {})
      Rack::Cache.new(backend, {
        :entitystore => "file:tmp/cache/entity",
        :metastore => "file:tmp/cache/meta",
        :verbose => false,
        :allow_reload => false,
        :allow_revalidate => false
      }.merge(options))
    end

    def self.clear
      [metastores.values + entitystores.values].flatten.each do |store|
        case store
        when Rack::Cache::EntityStore::Disk, Rack::Cache::MetaStore::Disk
          Dir[File.join(store.root, '*')].each do |file|
            FileUtils.rm_rf(file)
          end
        end
      end
    end
    
    def self.metastores
      Rack::Cache::Storage.instance.instance_variable_get('@metastores')
    end
    
    def self.entitystores
      Rack::Cache::Storage.instance.instance_variable_get('@entitystores')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radiant-rails3-0.1 lib/radiant/cache.rb