Class: Rack::Cache::EntityStore::MemCacheBase

Inherits:
Rack::Cache::EntityStore show all
Extended by:
Utils
Defined in:
lib/rack/cache/entity_store.rb

Overview

Base class for memcached entity stores.

Direct Known Subclasses

Dalli, MemCached

Constant Summary

Constants inherited from Rack::Cache::EntityStore

DISK, FILE, GAE, GAECACHE, HEAP, MEM, MEMCACHE, MEMCACHED, NOOP

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cacheObject (readonly)

The underlying Memcached instance used to communicate with the memcached daemon.



175
176
177
# File 'lib/rack/cache/entity_store.rb', line 175

def cache
  @cache
end

Class Method Details

.resolve(uri) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/rack/cache/entity_store.rb', line 184

def self.resolve(uri)
  if uri.respond_to?(:scheme)
    server = "#{uri.host}:#{uri.port || '11211'}"
    options = parse_query(uri.query)
    options.keys.each do |key|
      value =
        case value = options.delete(key)
        when 'true' ; true
        when 'false' ; false
        else value.to_sym
        end
      options[key.to_sym] = value
    end
    options[:namespace] = uri.path.sub(/^\//, '')
    new server, options
  else
    # if the object provided is not a URI, pass it straight through
    # to the underlying implementation.
    new uri
  end
end

Instance Method Details

#open(key) ⇒ Object



179
180
181
182
# File 'lib/rack/cache/entity_store.rb', line 179

def open(key)
  data = read(key)
  data && [data]
end