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.



426
427
428
429
430
# File 'lib/memcache.rb', line 426

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.



424
425
426
# File 'lib/memcache.rb', line 424

def fallback
  @fallback
end

Instance Method Details

#[](scope) ⇒ Object



440
441
442
# File 'lib/memcache.rb', line 440

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

#[]=(scope, cache) ⇒ Object



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

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

#include?(scope) ⇒ Boolean

Returns:

  • (Boolean)


432
433
434
# File 'lib/memcache.rb', line 432

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

#resetObject



448
449
450
# File 'lib/memcache.rb', line 448

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