Class: Hg::Redis

Inherits:
Object
  • Object
show all
Defined in:
lib/hg/redis.rb

Overview

Represents our connection to a Redis instance.

Class Method Summary collapse

Class Method Details

.execute(&block) ⇒ Object

TODO: test



13
14
15
16
17
# File 'lib/hg/redis.rb', line 13

def execute(&block)
  pool.with do |conn|
    yield(conn)
  end
end

.poolObject

TODO: test



5
6
7
8
9
10
# File 'lib/hg/redis.rb', line 5

def pool
  # TODO: Should enable setting connection pool size/timeout/redis URL as config option on Hg
  @pool ||= ConnectionPool.new(size: ENV['REDIS_CONNECTION_POOL_SIZE'], timeout: 5) do
    ::Redis.new(url: ENV['REDIS_URL'] || 'redis://localhost:6379')
  end
end