class Rack::Cache::EntityStore::Dalli
Uses the Dalli
ruby library. This is the default unless the memcached library has already been required.
Public Class Methods
Source
# File lib/rack/cache/entity_store.rb 210 def initialize(server="localhost:11211", options={}) 211 @cache = 212 if server.respond_to?(:stats) 213 server 214 else 215 require 'dalli' 216 ::Dalli::Client.new(server, options) 217 end 218 end
Public Instance Methods
Source
# File lib/rack/cache/entity_store.rb 220 def exist?(key) 221 !cache.get(key).nil? 222 end
Source
# File lib/rack/cache/entity_store.rb 236 def purge(key) 237 cache.delete(key) 238 nil 239 end
Source
# File lib/rack/cache/entity_store.rb 224 def read(key) 225 data = cache.get(key) 226 data.force_encoding('BINARY') if data.respond_to?(:force_encoding) 227 data 228 end
Source
# File lib/rack/cache/entity_store.rb 230 def write(body, ttl=nil) 231 buf = StringIO.new 232 key, size = slurp(body){|part| buf.write(part) } 233 [key, size] if cache.set(key, buf.string, ttl) 234 end