class Rack::Cache::MetaStore::MemCacheBase

Stores request/response pairs in memcached. Keys are not stored directly since memcached has a 250-byte limit on key names. Instead, the SHA1 hexdigest of the key is used.

Attributes

cache[R]

The MemCache object used to communicated with the memcached daemon.

Public Class Methods

resolve(uri) click to toggle source

Create MemCache store for the given URI. The URI must specify a host and may specify a port, namespace, and options:

memcached://example.com:11211/namespace?opt1=val1&opt2=val2

Query parameter names and values are documented with the memcached library: tinyurl.com/4upqnd

    # File lib/rack/cache/meta_store.rb
297 def self.resolve(uri)
298   if uri.respond_to?(:scheme)
299     server = "#{uri.host}:#{uri.port || '11211'}"
300     options = parse_query(uri.query)
301     options.keys.each do |key|
302       value =
303         case value = options.delete(key)
304         when 'true' ; true
305         when 'false' ; false
306         else value.to_sym
307         end
308       options[key.to_sym] = value
309     end
310 
311     options[:namespace] = uri.path.to_s.sub(/^\//, '')
312 
313     new server, options
314   else
315     # if the object provided is not a URI, pass it straight through
316     # to the underlying implementation.
317     new uri
318   end
319 end