Class: Rack::Cache::EntityStore::MEM

### Home Classes Methods

### In Files

- lib/rack/cache/entitystore.rb

### Parent

Rack::Cache::EntityStore

### Methods

- ::new
- ::resolve
- #exist?
- #open
- #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::EntityStore::MEM

Stores entity bodies on the heap using a Hash object.

### Public Class Methods

new(hash={}) click to toggle source

Create the store with the specified backing Hash.

    # File lib/rack/cache/entitystore.rb, line 38
    def initialize(hash={})
      @hash = hash
    end

resolve(uri) click to toggle source

    # File lib/rack/cache/entitystore.rb, line 74
    def self.resolve(uri)
      new
    end

### Public Instance Methods

exist?(key) click to toggle source

Determine whether the response body with the specified key (SHA1) exists in the store.

    # File lib/rack/cache/entitystore.rb, line 44
    def exist?(key)
      @hash.include?(key)
    end

open(key) click to toggle source

Return an object suitable for use as a Rack response body for the specified key.

    # File lib/rack/cache/entitystore.rb, line 50
    def open(key)
      (body = @hash[key]) && body.dup
    end

purge(key) click to toggle source

Remove the body corresponding to key; return nil.

    # File lib/rack/cache/entitystore.rb, line 69
    def purge(key)
      @hash.delete(key)
      nil
    end

read(key) click to toggle source

Read all data associated with the given key and return as a single String.

    # File lib/rack/cache/entitystore.rb, line 56
    def read(key)
      (body = @hash[key]) && body.join
    end

write(body, ttl=nil) click to toggle source

Write the Rack response body immediately and return the SHA1 key.

    # File lib/rack/cache/entitystore.rb, line 61
    def write(body, ttl=nil)
      buf = []
      key, size = slurp(body) { |part| buf << part }
      @hash[key] = buf
      [key, size]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.