Class: Rack::Cache::MetaStore::MemCache
- Inherits:
-
MemCacheBase
- Object
- Rack::Cache::MetaStore
- MemCacheBase
- Rack::Cache::MetaStore::MemCache
- Defined in:
- lib/rack/cache/metastore.rb
Constant Summary
Constants inherited from Rack::Cache::MetaStore
DISK, FILE, GAE, GAECACHE, HEAP, MEM, MEMCACHE, MEMCACHED
Instance Attribute Summary
Attributes inherited from MemCacheBase
Instance Method Summary collapse
-
#initialize(server = "localhost:11211", options = {}) ⇒ MemCache
constructor
A new instance of MemCache.
- #purge(key) ⇒ Object
- #read(key) ⇒ Object
- #write(key, entries) ⇒ Object
Methods inherited from MemCacheBase
Methods inherited from Rack::Cache::MetaStore
#cache_key, #invalidate, #lookup, #store
Constructor Details
#initialize(server = "localhost:11211", options = {}) ⇒ MemCache
Returns a new instance of MemCache.
302 303 304 305 306 307 308 309 310 |
# File 'lib/rack/cache/metastore.rb', line 302 def initialize(server="localhost:11211", ={}) @cache = if server.respond_to?(:stats) server else require 'memcache' ::MemCache.new(server, ) end end |
Instance Method Details
#purge(key) ⇒ Object
322 323 324 325 |
# File 'lib/rack/cache/metastore.rb', line 322 def purge(key) cache.delete(hexdigest(key)) nil end |
#read(key) ⇒ Object
312 313 314 315 |
# File 'lib/rack/cache/metastore.rb', line 312 def read(key) key = hexdigest(key) cache.get(key) || [] end |
#write(key, entries) ⇒ Object
317 318 319 320 |
# File 'lib/rack/cache/metastore.rb', line 317 def write(key, entries) key = hexdigest(key) cache.set(key, entries) end |