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 367 def initialize(server="localhost:11211", options={}) 368 options[:prefix_key] ||= options.delete(:namespace) if options.key?(:namespace) 369 @cache = 370 if server.respond_to?(:stats) 371 server 372 else 373 require 'memcached' 374 Memcached.new(server, options) 375 end 376 end
Public Instance Methods
purge(key)
click to toggle source
# File lib/rack/cache/meta_store.rb 391 def purge(key) 392 key = hexdigest(key) 393 cache.delete(key) 394 nil 395 rescue Memcached::NotFound 396 nil 397 end
read(key)
click to toggle source
# File lib/rack/cache/meta_store.rb 378 def read(key) 379 key = hexdigest(key) 380 cache.get(key) 381 rescue Memcached::NotFound 382 [] 383 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 386 def write(key, entries, ttl = 0) 387 key = hexdigest(key) 388 cache.set(key, entries, ttl) 389 end