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

Uses the memcache-client 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 'memcache'
216:             ::MemCache.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 234
234:       def purge(key)
235:         cache.delete(key)
236:         nil
237:       end

[Source]

     # File lib/rack/cache/entitystore.rb, line 224
224:       def read(key)
225:         cache.get(key)
226:       end

[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

[Validate]