module Godredis

Godredis: bulk managing multiply Redis instances

Godredis provides unified interface for mass managing Redis connections which could be initialized in different modules having each own custom API.

It is useful when you need to close or reset connections on forking, for example, with puma server in the on_restart block:

on_restart do
  # Rails.cache.instance_variable_get('@data').quit
  # Redis::Objects.redis.quit
  # Sidekiq.redis(&:quit)
  Godredis.quit_all!  # instead of commented lines above
end

There are several ways to call bulk commands with Godredis:

# Godredis.command_all! -- will output command execution result
Godredis.reconnect_all! # => Redis [cache_store]: reconnect... [OK]
                        # => Redis [objects]: reconnect... [OK]
                        # => Redis [sidekiq]: reconnect... [OK]

# Godredis.command_all -- silent
Godredis.quit_all

# Just different syntax
Godredis.redises(&:quit) 
Godredis.redises(&:quit!)

# It's also return an enumerator, so you can do something like this:
Godredis.redises.map(&:connected?)

See Godredis::Base documentation for collecting your Redis-related objects.