Class Rack::Cache::MetaStore::MemCacheBase

  1. lib/rack/cache/metastore.rb

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.

Methods

public class

  1. resolve

Attributes

cache [R] The MemCache object used to communicated with the memcached daemon.

Public class methods

resolve (uri)

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

[show source]
     # File lib/rack/cache/metastore.rb, line 279
279:       def self.resolve(uri)
280:         if uri.respond_to?(:scheme)
281:           server = "#{uri.host}:#{uri.port || '11211'}"
282:           options = parse_query(uri.query)
283:           options.keys.each do |key|
284:             value =
285:               case value = options.delete(key)
286:               when 'true' ; true
287:               when 'false' ; false
288:               else value.to_sym
289:               end
290:             options[k.to_sym] = value
291:           end
292: 
293:           options[:namespace] = uri.path.to_s.sub(/^\//, '')
294: 
295:           new server, options
296:         else
297:           # if the object provided is not a URI, pass it straight through
298:           # to the underlying implementation.
299:           new uri
300:         end
301:       end