Sha256: affb9de239199b03f66cd39a6538cf25bb2b41b83d5ade8a2b6b64d8e5b3ade9
Contents?: true
Size: 749 Bytes
Versions: 8
Compression:
Stored size: 749 Bytes
Contents
require "redis" module Kredis::Connections mattr_accessor :connections, default: Hash.new mattr_accessor :configurator mattr_accessor :connector, default: ->(config) { Redis.new(config) } 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 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 end
Version data entries
8 entries across 8 versions & 1 rubygems