Class Rack::Cache::EntityStore::Dalli
In: lib/rack/cache/entitystore.rb
Parent: MemCacheBase

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

Methods

exist?   new   purge   read   write  

Public Class methods

[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

[Source]

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

[Source]

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

[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

[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

[Validate]