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
311 def self.resolve(uri)
312   if uri.respond_to?(:scheme)
313     server = "#{uri.host}:#{uri.port || '11211'}"
314     options = parse_query(uri.query)
315     options.keys.each do |key|
316       value =
317         case value = options.delete(key)
318         when 'true' ; true
319         when 'false' ; false
320         else value.to_sym
321         end
322       options[key.to_sym] = value
323     end
324 
325     options[:namespace] = uri.path.to_s.sub(/^\//, '')
326 
327     new server, options
328   else
329     # if the object provided is not a URI, pass it straight through
330     # to the underlying implementation.
331     new uri
332   end
333 end