Class: Moneta::Pool
Overview
Creates a pool of stores. Each thread gets its own store.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(options = {}, &block) ⇒ Pool
constructor
A new instance of Pool.
Methods inherited from Wrapper
#clear, #create, #delete, #features, #increment, #key?, #load, #store
Methods inherited from Proxy
#clear, #create, #delete, #features, #increment, #key?, #load, #store
Methods included from Defaults
#[], #[]=, #create, #decrement, #features, #fetch, included, #increment, #key?, #supports?
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
#initialize(options = {}, &block) ⇒ Pool
Returns a new instance of Pool.
20 21 22 23 24 25 26 |
# File 'lib/moneta/pool.rb', line 20 def initialize( = {}, &block) super(nil) @mutex = [:mutex] || ::Mutex.new @id = "Moneta::Pool(#{object_id})" @builder = Builder.new(&block) @pool, @all = [], [] end |
Instance Method Details
#close ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/moneta/pool.rb', line 28 def close @mutex.synchronize do raise '#close can only be called when no thread is using the pool' if @all.size != @pool.size @all.each(&:close) @all = @pool = nil end end |