class Rack::Cache::MetaStore::MemCached
Attributes
The Memcached instance used to communicated with the memcached daemon.
Public Class Methods
Source
# File lib/rack/cache/meta_store.rb, line 367 def initialize(server="localhost:11211", options={}) options[:prefix_key] ||= options.delete(:namespace) if options.key?(:namespace) @cache = if server.respond_to?(:stats) server else require 'memcached' Memcached.new(server, options) end end
Public Instance Methods
Source
# File lib/rack/cache/meta_store.rb, line 391 def purge(key) key = hexdigest(key) cache.delete(key) nil rescue Memcached::NotFound nil end
Source
# File lib/rack/cache/meta_store.rb, line 378 def read(key) key = hexdigest(key) cache.get(key) rescue Memcached::NotFound [] end
Source
# File lib/rack/cache/meta_store.rb, line 386 def write(key, entries, ttl = 0) key = hexdigest(key) cache.set(key, entries, ttl) end
Default TTL to zero, interpreted as “don’t expire” by Memcached.