Module: Redisable::Connection

Defined in:
lib/redisable/connection.rb

Class Method Summary collapse

Class Method Details

.conn(server) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/redisable/connection.rb', line 4

def self.conn(server)
  @pool ||= {}
  @pool[server] ||=
    begin
      conf = Redisable::Config.conf(server)
      redis = ::Redis.new(conf)
      raise "Redis server[#{conf["host"]}:#{conf["port"]}] is down!" unless reachable?(redis)
      redis
    end
end

.quit(server) ⇒ Object



15
16
17
18
19
# File 'lib/redisable/connection.rb', line 15

def self.quit(server)
  redis = @pool[server]
  redis.quit if redis && reachable?(redis)
  @pool[server] = nil
end

.reset(server) ⇒ Object



21
22
23
24
# File 'lib/redisable/connection.rb', line 21

def self.reset(server)
  quit(server)
  conn(server)
end