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