module Redis::Commands::Cluster

Public Instance Methods

asking() click to toggle source

Sends ‘ASKING` command to random node and returns its reply.

@see redis.io/topics/cluster-spec#ask-redirection ASK redirection

@return [String] ‘’OK’‘

# File lib/redis/commands/cluster.rb, line 40
def asking
  send_command(%i[asking])
end
cluster(subcommand, *args) click to toggle source

Sends ‘CLUSTER *` command to random node and returns its reply.

@see redis.io/commands#cluster Reference of cluster command

@param subcommand [String, Symbol] the subcommand of cluster command

e.g. `:slots`, `:nodes`, `:slaves`, `:info`

@return [Object] depends on the subcommand

# File lib/redis/commands/cluster.rb, line 14
def cluster(subcommand, *args)
  subcommand = subcommand.to_s.downcase
  block = case subcommand
  when 'slots'
    HashifyClusterSlots
  when 'nodes'
    HashifyClusterNodes
  when 'slaves'
    HashifyClusterSlaves
  when 'info'
    HashifyInfo
  else
    Noop
  end

  # @see https://github.com/antirez/redis/blob/unstable/src/redis-trib.rb#L127 raw reply expected
  block = Noop unless @cluster_mode

  send_command([:cluster, subcommand] + args, &block)
end