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, #each_key, #features, #fetch_values, #increment, #key?, #load, #merge!, #slice, #store, #values_at
Methods inherited from Proxy
#clear, #create, #delete, #each_key, #features, features_mask, #fetch_values, #increment, #key?, #load, #merge!, not_supports, #slice, #store, #values_at
Methods included from Defaults
#[], #[]=, #create, #decrement, #each_key, #features, #fetch, #fetch_values, included, #increment, #key?, #merge!, #slice, #supports?, #update, #values_at
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
#initialize(options = {}, &block) ⇒ Pool
Returns a new instance of Pool.
19 20 21 22 23 24 25 |
# File 'lib/moneta/pool.rb', line 19 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
27 28 29 30 31 32 33 |
# File 'lib/moneta/pool.rb', line 27 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 |