Module: Kredis::Connections

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

Instance Method Summary collapse

Instance Method Details

#clear_allObject



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

def clear_all
  Kredis.instrument :meta, message: "Connections all cleared" do
    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
end

#configured_for(name) ⇒ Object



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

def configured_for(name)
  connections[name] ||= begin
    Kredis.instrument :meta, message: "Connected to #{name}" do
      connector.call configurator.config_for("redis/#{name}")
    end
  end
end