Uses the memcache-client ruby library. This is the default unless the memcached library has already been required.
# File lib/rack/cache/entitystore.rb, line 210 def initialize(server="localhost:11211", options={}) @cache = if server.respond_to?(:stats) server else require 'memcache' ::MemCache.new(server, options) end end
# File lib/rack/cache/entitystore.rb, line 220 def exist?(key) !cache.get(key).nil? end
# File lib/rack/cache/entitystore.rb, line 234 def purge(key) cache.delete(key) nil end
# File lib/rack/cache/entitystore.rb, line 224 def read(key) cache.get(key) end
# File lib/rack/cache/entitystore.rb, line 228 def write(body) buf = StringIO.new key, size = slurp(body){|part| buf.write(part) } [key, size] if cache.set(key, buf.string) end