Class: Rack::Cache::EntityStore::Dalli

### Home Classes Methods

### In Files

- lib/rack/cache/entitystore.rb

### Parent

Rack::Cache::EntityStore::MemCacheBase

### Methods

- ::new
- #exist?
- #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::Dalli

Uses the Dalli ruby library. This is the default unless the memcached library has already been required.

### Public Class Methods

new(server="localhost:11211", options={}) click to toggle source

    # File lib/rack/cache/entitystore.rb, line 210
    def initialize(server="localhost:11211", options={})
      @cache =
        if server.respond_to?(:stats)
          server
        else
          require 'dalli'
          ::Dalli::Client.new(server, options)
        end
    end

### Public Instance Methods

exist?(key) click to toggle source

    # File lib/rack/cache/entitystore.rb, line 220
    def exist?(key)
      !cache.get(key).nil?
    end

purge(key) click to toggle source

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

read(key) click to toggle source

    # File lib/rack/cache/entitystore.rb, line 224
    def read(key)
      data = cache.get(key)
      data.force_encoding('BINARY') if data.respond_to?(:force_encoding)
      data
    end

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

    # File lib/rack/cache/entitystore.rb, line 230
    def write(body, ttl=nil)
      buf = StringIO.new
      key, size = slurp(body){|part| buf.write(part) }
      [key, size] if cache.set(key, buf.string, ttl)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.