module Redis::Commands

Constants

Boolify

Commands returning 1 for true and 0 for false may be executed in a pipeline where the method call will return nil. Propagate the nil instead of falsely returning false.

BoolifySet
EMPTY_STREAM_RESPONSE
Floatify
FloatifyPairs
Hashify
HashifyClusterNodeInfo
HashifyClusterNodes
HashifyClusterSlaves
HashifyClusterSlots
HashifyInfo
HashifyStreamAutoclaim
HashifyStreamAutoclaimJustId
HashifyStreamEntries
HashifyStreamPendingDetails
HashifyStreamPendings
HashifyStreams
Noop
Pairify

Public Instance Methods

call(*command) click to toggle source

Sends a command to Redis and returns its reply.

Replies are converted to Ruby objects according to the RESP protocol, so you can expect a Ruby array, integer or nil when Redis sends one. Higher level transformations, such as converting an array of pairs into a Ruby hash, are up to consumers.

Redis error replies are raised as Ruby exceptions.

# File lib/redis/commands.rb, line 202
def call(*command)
  send_command(command)
end
sentinel(subcommand, *args) click to toggle source

Interact with the sentinel command (masters, master, slaves, failover)

@param [String] subcommand e.g. ‘masters`, `master`, `slaves` @param [Array<String>] args depends on subcommand @return [Array<String>, Hash<String, String>, String] depends on subcommand

# File lib/redis/commands.rb, line 211
def sentinel(subcommand, *args)
  subcommand = subcommand.to_s.downcase
  send_command([:sentinel, subcommand] + args) do |reply|
    case subcommand
    when "get-master-addr-by-name"
      reply
    else
      if reply.is_a?(Array)
        if reply[0].is_a?(Array)
          reply.map(&Hashify)
        else
          Hashify.call(reply)
        end
      else
        reply
      end
    end
  end
end

Private Instance Methods

method_missing(*command) click to toggle source
# File lib/redis/commands.rb, line 233
def method_missing(*command) # rubocop:disable Style/MissingRespondToMissing
  send_command(command)
end