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.



374
375
376
377
378
# File 'lib/memcache.rb', line 374

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.



372
373
374
# File 'lib/memcache.rb', line 372

def fallback
  @fallback
end

Instance Method Details

#[](scope) ⇒ Object



388
389
390
# File 'lib/memcache.rb', line 388

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

#[]=(scope, cache) ⇒ Object



392
393
394
# File 'lib/memcache.rb', line 392

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

#include?(scope) ⇒ Boolean

Returns:

  • (Boolean)


380
381
382
# File 'lib/memcache.rb', line 380

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

#resetObject



396
397
398
# File 'lib/memcache.rb', line 396

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