class RedisClient::Pooled
Constants
- EMPTY_HASH
Public Class Methods
Source
# File lib/redis_client/pooled.rb, line 11 def initialize( config, id: config.id, connect_timeout: config.connect_timeout, read_timeout: config.read_timeout, write_timeout: config.write_timeout, **kwargs ) super(config, id: id, connect_timeout: connect_timeout, read_timeout: read_timeout, write_timeout: write_timeout) @pool_kwargs = kwargs @pool = new_pool @mutex = Mutex.new end
Calls superclass method
RedisClient::Common::new
Public Instance Methods
Source
# File lib/redis_client/pooled.rb, line 37 def close if @pool @mutex.synchronize do pool = @pool @pool = nil pool&.shutdown(&:close) end end nil end
Source
# File lib/redis_client/pooled.rb, line 25 def with(options = EMPTY_HASH) pool.with(options) do |client| client.connect_timeout = connect_timeout client.read_timeout = read_timeout client.write_timeout = write_timeout yield client end rescue ConnectionPool::TimeoutError => error raise CheckoutTimeoutError, "Couldn't checkout a connection in time: #{error.message}" end
Also aliased as: then
Private Instance Methods
Source
# File lib/redis_client/pooled.rb, line 82 def new_pool ConnectionPool.new(**@pool_kwargs) { @config.new_client } end
Source
# File lib/redis_client/pooled.rb, line 78 def pool @pool ||= @mutex.synchronize { new_pool } end