Class: Rack::Cache::MetaStore::FILE

### Home Classes Methods

### In Files

- lib/rack/cache/metastore.rb

### Parent

Rack::Cache::MetaStore

### Methods

- ::new
- ::resolve
- #purge
- #read
- #write

### Files

- CHANGES
- COPYING
- README
- TODO

### Class/Module Index

Quicksearch

- Rack
- Rack::Cache
- Rack::Cache::AppEngine
- Rack::Cache::AppEngine::MC
- Rack::Cache::AppEngine::MemCache
- Rack::Cache::CacheControl
- Rack::Cache::Context
- Rack::Cache::EntityStore
- Rack::Cache::EntityStore::DISK
- Rack::Cache::EntityStore::Dalli
- Rack::Cache::EntityStore::Disk
- Rack::Cache::EntityStore::FILE
- Rack::Cache::EntityStore::GAE
- Rack::Cache::EntityStore::GAECACHE
- Rack::Cache::EntityStore::GAEStore
- Rack::Cache::EntityStore::HEAP
- Rack::Cache::EntityStore::Heap
- Rack::Cache::EntityStore::MEM
- Rack::Cache::EntityStore::MemCacheBase
- Rack::Cache::EntityStore::MemCached
- Rack::Cache::Key
- Rack::Cache::MetaStore
- Rack::Cache::MetaStore::DISK
- Rack::Cache::MetaStore::Dalli
- Rack::Cache::MetaStore::Disk
- Rack::Cache::MetaStore::FILE
- Rack::Cache::MetaStore::GAE
- Rack::Cache::MetaStore::GAECACHE
- Rack::Cache::MetaStore::GAEStore
- Rack::Cache::MetaStore::HEAP
- Rack::Cache::MetaStore::Heap
- Rack::Cache::MetaStore::MEM
- Rack::Cache::MetaStore::MemCacheBase
- Rack::Cache::MetaStore::MemCached
- Rack::Cache::Options
- Rack::Cache::Request
- Rack::Cache::Response
- Rack::Cache::Storage

No matching classes.

# Rack::Cache::MetaStore::FILE

Concrete MetaStore implementation that stores request/response pairs on disk.

### Attributes

root[R]

### Public Class Methods

new(root="/tmp/rack-cache/meta-#{ARGV[0]}") click to toggle source

    # File lib/rack/cache/metastore.rb, line 216
    def initialize(root="/tmp/rack-cache/meta-#{ARGV[0]}")
      @root = File.expand_path(root)
      FileUtils.mkdir_p(root, :mode => 0755)
    end

resolve(uri) click to toggle source

    # File lib/rack/cache/metastore.rb, line 259
    def self.resolve(uri)
      path = File.expand_path(uri.opaque || uri.path)
      new path
    end

### Public Instance Methods

purge(key) click to toggle source

    # File lib/rack/cache/metastore.rb, line 239
    def purge(key)
      path = key_path(key)
      File.unlink(path)
      nil
    rescue Errno::ENOENT, IOError
      nil
    end

read(key) click to toggle source

    # File lib/rack/cache/metastore.rb, line 221
    def read(key)
      path = key_path(key)
      File.open(path, 'rb') { |io| Marshal.load(io) }
    rescue Errno::ENOENT, IOError
      []
    end

write(key, entries) click to toggle source

    # File lib/rack/cache/metastore.rb, line 228
    def write(key, entries)
      tries = 0
      begin
        path = key_path(key)
        File.open(path, 'wb') { |io| Marshal.dump(entries, io, -1) }
      rescue Errno::ENOENT, IOError
        Dir.mkdir(File.dirname(path), 0755)
        retry if (tries += 1) == 1
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.