File: cluster.rb

package info (click to toggle)
ruby-redis 5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,160 kB
  • sloc: ruby: 11,445; makefile: 117; sh: 24
file content (28 lines) | stat: -rw-r--r-- 811 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 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)
        send_command([:cluster, subcommand] + args)
      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