Module: Kredis::Connections

Included in:
Kredis
Defined in:
lib/kredis/connections.rb

Instance Method Summary collapse

Instance Method Details

#clear_allObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kredis/connections.rb', line 14

def clear_all
  logger&.info "[Kredis] Connections all cleared"
  connections.each_value do |connection|
    if Kredis.namespace
      keys = connection.keys("#{Kredis.namespace}:*")
      connection.del keys if keys.any?
    else
      connection.flushdb
    end
  end
end

#configured_for(name) ⇒ Object



7
8
9
10
11
12
# File 'lib/kredis/connections.rb', line 7

def configured_for(name)
  connections[name] ||= begin
    logger&.info "[Kredis] Connected to #{name}"
    Redis.new configurator.config_for("redis/#{name}")
  end
end