Class: Redis::Pool
- Inherits:
-
Redis
- Object
- Redis
- Redis::Pool
- Defined in:
- lib/redis/pool.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#pool ⇒ Object
readonly
Returns the value of attribute pool.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Pool
constructor
A new instance of Pool.
- #multi ⇒ Object
- #pipelined ⇒ Object
- #synchronize ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Pool
Returns a new instance of Pool.
9 10 11 12 13 14 |
# File 'lib/redis/pool.rb', line 9 def initialize( = {}) @pool = ConnectionPool.new(size: .delete(:size)) { Redis::Client.new() } @id = "Redis::Pool::#{object_id}" super end |
Instance Attribute Details
#pool ⇒ Object (readonly)
Returns the value of attribute pool.
7 8 9 |
# File 'lib/redis/pool.rb', line 7 def pool @pool end |
Instance Method Details
#multi ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/redis/pool.rb', line 34 def multi raise ArgumentError, "Redis::Pool#multi can only be called with a block" unless block_given? pipeline = Pipeline::Multi.new _with_client(pipeline) do |client| yield(client) end synchronize do |client| client.call_pipeline(pipeline) end end |
#pipelined ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/redis/pool.rb', line 22 def pipelined pipeline = Pipeline.new _with_client(pipeline) do |client| yield(client) end synchronize do |client| client.call_pipeline(pipeline) end end |
#synchronize ⇒ Object
16 17 18 19 20 |
# File 'lib/redis/pool.rb', line 16 def synchronize @pool.with do |client| _with_client(client) { yield(client) } end end |