Sha256: f227ee0319818ef679d33bdc3a5cc70162cf17beb4c22118f860ec1dfbff1dde

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

class Redis
  module Commands
    module Cluster
      # Sends `CLUSTER *` command to random node and returns its reply.
      #
      # @see https://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
      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

      # Sends `ASKING` command to random node and returns its reply.
      #
      # @see https://redis.io/topics/cluster-spec#ask-redirection ASK redirection
      #
      # @return [String] `'OK'`
      def asking
        send_command(%i[asking])
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/redis-4.8.1/lib/redis/commands/cluster.rb
redis-4.8.1 lib/redis/commands/cluster.rb
redis-4.8.0 lib/redis/commands/cluster.rb
redis-4.7.1 lib/redis/commands/cluster.rb
redis-4.7.0 lib/redis/commands/cluster.rb
redis-4.6.0 lib/redis/commands/cluster.rb