Class: Rack::Cache::MetaStore::MemCacheBase
- Inherits:
-
Rack::Cache::MetaStore
- Object
- Rack::Cache::MetaStore
- Rack::Cache::MetaStore::MemCacheBase
- Extended by:
- Utils
- Defined in:
- lib/rack/cache/metastore.rb
Overview
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.
Constant Summary
Constants inherited from Rack::Cache::MetaStore
DISK, FILE, GAE, GAECACHE, HEAP, MEM, MEMCACHE, MEMCACHED
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
The MemCache object used to communicated with the memcached daemon.
Class Method Summary collapse
-
.resolve(uri) ⇒ Object
Create MemCache store for the given URI.
Methods inherited from Rack::Cache::MetaStore
#cache_key, #invalidate, #lookup, #store
Instance Attribute Details
#cache ⇒ Object (readonly)
The MemCache object used to communicated with the memcached daemon.
267 268 269 |
# File 'lib/rack/cache/metastore.rb', line 267 def cache @cache end |
Class Method Details
.resolve(uri) ⇒ Object
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
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/rack/cache/metastore.rb', line 276 def self.resolve(uri) if uri.respond_to?(:scheme) server = "#{uri.host}:#{uri.port || '11211'}" = parse_query(uri.query) .keys.each do |key| value = case value = .delete(key) when 'true' ; true when 'false' ; false else value.to_sym end [k.to_sym] = value end [:namespace] = uri.path.to_s.sub(/^\//, '') new server, else # if the object provided is not a URI, pass it straight through # to the underlying implementation. new uri end end |