Class: Redis::Cluster::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/cluster/command.rb

Overview

Keep details about Redis commands for Redis Cluster Client.

Instance Method Summary collapse

Constructor Details

#initialize(details) ⇒ Command

Returns a new instance of Command.



10
11
12
# File 'lib/redis/cluster/command.rb', line 10

def initialize(details)
  @details = pick_details(details)
end

Instance Method Details

#extract_first_key(command) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/redis/cluster/command.rb', line 14

def extract_first_key(command)
  i = determine_first_key_position(command)
  return '' if i == 0

  key = command[i].to_s
  hash_tag = extract_hash_tag(key)
  hash_tag.empty? ? key : hash_tag
end

#should_send_to_master?(command) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/redis/cluster/command.rb', line 23

def should_send_to_master?(command)
  dig_details(command, :write)
end

#should_send_to_slave?(command) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/redis/cluster/command.rb', line 27

def should_send_to_slave?(command)
  dig_details(command, :readonly)
end