Class: Moneta::Pool
Overview
Creates a thread-safe pool. Stores are in the pool are transparently checked in and out in order to perform operations.
A ‘max` setting can be specified in order to limit the pool size. If `max` stores are all checked out at once, the next check-out will block until one of the other stores are checked in.
A ‘ttl` setting can be specified, giving the number of seconds to wait without any activity before shrinking the pool size back down to the min size.
A ‘timeout` setting can be specified, giving the number of seconds to wait when checking out a store, before an error is raised. When the pool has a `:max` size, a timeout is highly advisable.
Defined Under Namespace
Classes: PoolManager, Reply, ShutdownError, TimeoutError
Instance Method Summary collapse
-
#close ⇒ Object
Closing has no effect on the pool, as stores are closed in the background by the manager after the ttl.
-
#initialize(options = {}) { ... } ⇒ Pool
constructor
A new instance of Pool.
- #stats ⇒ Object
-
#stop ⇒ Object
Tells the manager to close all stores.
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 = {}) { ... } ⇒ Pool
Returns a new instance of Pool.
291 292 293 294 295 |
# File 'lib/moneta/pool.rb', line 291 def initialize( = {}, &block) super(nil) @id = "Moneta::Pool(#{object_id})" @manager = PoolManager.new(Builder.new(&block), **) end |
Instance Method Details
#close ⇒ Object
Closing has no effect on the pool, as stores are closed in the background by the manager after the ttl
299 |
# File 'lib/moneta/pool.rb', line 299 def close; end |
#stats ⇒ Object
308 309 310 |
# File 'lib/moneta/pool.rb', line 308 def stats @manager.stats end |
#stop ⇒ Object
Tells the manager to close all stores. It will not be possible to use the store after this.
303 304 305 306 |
# File 'lib/moneta/pool.rb', line 303 def stop @manager.stop nil end |