Module: Stockpile::RedisConnection

Defined in:
lib/stockpile/redis_connection.rb

Overview

Stockpile::RedisConnection

Wrapper around ConnectionPool and Redis to provide connectivity to Redis with desired configuration and sane connection pool

Class Method Summary collapse

Class Method Details

.connection_optionsObject



31
32
33
34
# File 'lib/stockpile/redis_connection.rb', line 31

def connection_options
  { url: redis_url,
    sentinels: sentinels }
end

.connection_poolObject



25
26
27
28
29
# File 'lib/stockpile/redis_connection.rb', line 25

def connection_pool
  @connection_pool = ConnectionPool.new(connection_pool_options) do
    Redis.new(connection_options)
  end
end

.connection_pool_optionsObject



36
37
38
39
# File 'lib/stockpile/redis_connection.rb', line 36

def connection_pool_options
  { size: pool_size,
    timeout: connection_timeout }
end

.connection_timeoutObject



41
42
43
# File 'lib/stockpile/redis_connection.rb', line 41

def connection_timeout
  Stockpile.configuration.connection_timeout
end

.pool_sizeObject



45
46
47
# File 'lib/stockpile/redis_connection.rb', line 45

def pool_size
  Stockpile.configuration.connection_pool
end

.redis_urlObject



49
50
51
# File 'lib/stockpile/redis_connection.rb', line 49

def redis_url
  Stockpile.configuration.redis_url
end

.sentinelsObject



53
54
55
# File 'lib/stockpile/redis_connection.rb', line 53

def sentinels
  Stockpile.configuration.sentinels
end