Class Rack::Cache::MetaStore::MemCached
In: lib/rack/cache/metastore.rb
Parent: MemCacheBase

Methods

new   purge   read   write  

Attributes

cache  [R]  The Memcached instance used to communicated with the memcached daemon.

Public Class methods

[Source]

     # File lib/rack/cache/metastore.rb, line 343
343:       def initialize(server="localhost:11211", options={})
344:         options[:prefix_key] ||= options.delete(:namespace) if options.key?(:namespace)
345:         @cache =
346:           if server.respond_to?(:stats)
347:             server
348:           else
349:             require 'memcached'
350:             Memcached.new(server, options)
351:           end
352:       end

Public Instance methods

[Source]

     # File lib/rack/cache/metastore.rb, line 366
366:       def purge(key)
367:         key = hexdigest(key)
368:         cache.delete(key)
369:         nil
370:       rescue Memcached::NotFound
371:         nil
372:       end

[Source]

     # File lib/rack/cache/metastore.rb, line 354
354:       def read(key)
355:         key = hexdigest(key)
356:         cache.get(key)
357:       rescue Memcached::NotFound
358:         []
359:       end

[Source]

     # File lib/rack/cache/metastore.rb, line 361
361:       def write(key, entries)
362:         key = hexdigest(key)
363:         cache.set(key, entries)
364:       end

[Validate]