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