Class Rack::Cache::EntityStore::Dalli

  1. lib/rack/cache/entitystore.rb

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

Methods

public class

  1. new

public instance

  1. exist?
  2. purge
  3. read
  4. write

Public class methods

new (server="localhost:11211", options={})
[show 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)
[show source]
     # File lib/rack/cache/entitystore.rb, line 220
220:       def exist?(key)
221:         !cache.get(key).nil?
222:       end
purge (key)
[show source]
     # File lib/rack/cache/entitystore.rb, line 234
234:       def purge(key)
235:         cache.delete(key)
236:         nil
237:       end
read (key)
[show source]
     # File lib/rack/cache/entitystore.rb, line 224
224:       def read(key)
225:         cache.get(key)
226:       end
write (body)
[show source]
     # File lib/rack/cache/entitystore.rb, line 228
228:       def write(body)
229:         buf = StringIO.new
230:         key, size = slurp(body){|part| buf.write(part) }
231:         [key, size] if cache.set(key, buf.string)
232:       end