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
369 def initialize(server="localhost:11211", options={})
370   options[:prefix_key] ||= options.delete(:namespace) if options.key?(:namespace)
371   @cache =
372     if server.respond_to?(:stats)
373       server
374     else
375       require 'memcached'
376       Memcached.new(server, options)
377     end
378 end

Public Instance Methods

purge(key) click to toggle source
    # File lib/rack/cache/meta_store.rb
393 def purge(key)
394   key = hexdigest(key)
395   cache.delete(key)
396   nil
397 rescue Memcached::NotFound
398   nil
399 end
read(key) click to toggle source
    # File lib/rack/cache/meta_store.rb
380 def read(key)
381   key = hexdigest(key)
382   cache.get(key)
383 rescue Memcached::NotFound
384   []
385 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
388 def write(key, entries, ttl = 0)
389   key = hexdigest(key)
390   cache.set(key, entries, ttl)
391 end