class Rack::Cache::MetaStore::MemCached

Attributes

cache[R]

The Memcached instance used to communicated with the memcached daemon.

Public Class Methods

new(server="localhost:11211", options={}) click to toggle source
    # File lib/rack/cache/meta_store.rb
368 def initialize(server="localhost:11211", options={})
369   options[:prefix_key] ||= options.delete(:namespace) if options.key?(:namespace)
370   @cache =
371     if server.respond_to?(:stats)
372       server
373     else
374       require 'memcached'
375       Memcached.new(server, options)
376     end
377 end

Public Instance Methods

purge(key) click to toggle source
    # File lib/rack/cache/meta_store.rb
392 def purge(key)
393   key = hexdigest(key)
394   cache.delete(key)
395   nil
396 rescue Memcached::NotFound
397   nil
398 end
read(key) click to toggle source
    # File lib/rack/cache/meta_store.rb
379 def read(key)
380   key = hexdigest(key)
381   cache.get(key)
382 rescue Memcached::NotFound
383   []
384 end
write(key, entries, ttl = 0) click to toggle source

Default TTL to zero, interpreted as “don’t expire” by Memcached.

    # File lib/rack/cache/meta_store.rb
387 def write(key, entries, ttl = 0)
388   key = hexdigest(key)
389   cache.set(key, entries, ttl)
390 end