Class: RedisBatch::Client

Inherits:
Object
  • Object
show all
Extended by:
Configurable
Includes:
Singleton
Defined in:
lib/redis_batch/client.rb

Instance Method Summary collapse

Methods included from Configurable

configuration, configure, reset_configuration

Constructor Details

#initialize(configuration) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
14
15
16
17
# File 'lib/redis_batch/client.rb', line 9

def initialize(configuration)
  if configuration.redis.respond_to?(:with)
    @connection_pool = configuration.redis
  else
    @connection_pool = ConnectionPool.new(size: 1, timeout: 1) {
      configuration.redis
    }
  end
end

Instance Method Details

#pingObject



19
20
21
# File 'lib/redis_batch/client.rb', line 19

def ping
  @connection_pool.with(&:ping)
end

#poolObject



27
28
29
# File 'lib/redis_batch/client.rb', line 27

def pool
  @connection_pool
end

#withObject



23
24
25
# File 'lib/redis_batch/client.rb', line 23

def with(...)
  @connection_pool.with(...)
end