Class: Memcache::Pool

Inherits:
Object show all
Defined in:
lib/memcache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePool

Returns a new instance of Pool.



444
445
446
447
448
# File 'lib/memcache.rb', line 444

def initialize
  @cache_by_scope = {}
  @cache_by_scope[:default] = Memcache.new(:server => Memcache::LocalServer)
  @fallback = :default
end

Instance Attribute Details

#fallbackObject

Returns the value of attribute fallback.



442
443
444
# File 'lib/memcache.rb', line 442

def fallback
  @fallback
end

Instance Method Details

#[](scope) ⇒ Object



458
459
460
# File 'lib/memcache.rb', line 458

def [](scope)
  @cache_by_scope[scope.to_sym] || @cache_by_scope[fallback]
end

#[]=(scope, cache) ⇒ Object



462
463
464
# File 'lib/memcache.rb', line 462

def []=(scope, cache)
  @cache_by_scope[scope.to_sym] = cache
end

#include?(scope) ⇒ Boolean

Returns:

  • (Boolean)


450
451
452
# File 'lib/memcache.rb', line 450

def include?(scope)
  @cache_by_scope.include?(scope.to_sym)
end

#resetObject



466
467
468
# File 'lib/memcache.rb', line 466

def reset
  @cache_by_scope.values.each {|c| c.reset}
end