Class: Moneta::Pool

Inherits:
Wrapper show all
Defined in:
lib/moneta/pool.rb

Overview

Creates a pool of stores. Each thread gets its own store.

Examples:

Add `Moneta::Pool` to proxy stack

Moneta.build do
  use(:Pool) do
    # Every thread gets its own instance
    adapter :MemcachedNative
  end
end

Instance Method Summary collapse

Methods inherited from Wrapper

#clear, #close, #delete, #increment, #key?, #load, #store

Methods inherited from Proxy

#clear, #close, #delete, #increment, #key?, #load, #store

Methods included from Defaults

#[], #[]=, #close, #decrement, #fetch, #increment, #key?

Methods included from OptionSupport

#expires, #prefix, #raw, #with

Constructor Details

#initialize(options = {}, &block) ⇒ Pool

Returns a new instance of Pool

Parameters:

  • adapter (Moneta store)

    The underlying store

  • options (Hash) (defaults to: {})

17
18
19
20
21
# File 'lib/moneta/pool.rb', line 17

def initialize(options = {}, &block)
  super(nil)
  @builder = Builder.new(&block)
  @pool, @active = [], {}
end