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
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

exist?(key) click to toggle source
     # File lib/rack/cache/entitystore.rb, line 220
220:       def exist?(key)
221:         !cache.get(key).nil?
222:       end
purge(key) click to toggle source
     # File lib/rack/cache/entitystore.rb, line 236
236:       def purge(key)
237:         cache.delete(key)
238:         nil
239:       end
read(key) click to toggle source
     # File lib/rack/cache/entitystore.rb, line 224
224:       def read(key)
225:         data = cache.get(key)
226:         data.force_encoding('BINARY') if data.respond_to?(:force_encoding)
227:         data
228:       end
write(body, ttl=nil) click to toggle source
     # File lib/rack/cache/entitystore.rb, line 230
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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.