redis-cluster-client 0.16.6 → 0.16.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/redis_client/cluster/command.rb +8 -21
- data/lib/redis_client/cluster/node_key.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7b3e4681d84fa76e82207734150b10bfe7963c07f99988919cb6381bcc1be26
|
|
4
|
+
data.tar.gz: f00dfcd28b66eb101779396fc3237b385c03f1cd845bae82fd592ae34abe9746
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a0b9abb4d20edda5d576350d47f47fb0c181bc706d473ba39caa3faf0eae296e453ad25ee42debd4475cee32012260b1cc9753a9b382afb56392678dd4b9bbf
|
|
7
|
+
data.tar.gz: d272558440ca03e6473153cbfd7c39be0bcb0201c643801b4ff1950b0a6d2188d787e0a2c9e01efc596d82a088c2491e9a08e7efc9827ac9cf61c01152e8f878
|
|
@@ -9,12 +9,11 @@ class RedisClient
|
|
|
9
9
|
class Command
|
|
10
10
|
EMPTY_STRING = ''
|
|
11
11
|
EMPTY_HASH = {}.freeze
|
|
12
|
-
EMPTY_POLICIES = [nil, nil].freeze
|
|
13
12
|
REQUEST_POLICY_PREFIX = 'request_policy:'
|
|
14
13
|
RESPONSE_POLICY_PREFIX = 'response_policy:'
|
|
15
14
|
SUBCOMMAND_DELIMITER = '|'
|
|
16
15
|
|
|
17
|
-
private_constant :EMPTY_HASH, :
|
|
16
|
+
private_constant :EMPTY_HASH, :REQUEST_POLICY_PREFIX,
|
|
18
17
|
:RESPONSE_POLICY_PREFIX, :SUBCOMMAND_DELIMITER
|
|
19
18
|
|
|
20
19
|
# @see https://redis.io/docs/latest/commands/command/ The reply of the COMMAND command
|
|
@@ -105,15 +104,13 @@ class RedisClient
|
|
|
105
104
|
end
|
|
106
105
|
|
|
107
106
|
def build_spec(row)
|
|
108
|
-
request_policy, response_policy = parse_tips(row[7])
|
|
109
|
-
|
|
110
107
|
::RedisClient::Cluster::Command::Spec.new(
|
|
111
108
|
first_key_position: parse_first_key_position(row),
|
|
112
109
|
key_step: row[5],
|
|
113
110
|
write?: parse_writability(row),
|
|
114
111
|
readonly?: row[2].include?('readonly'),
|
|
115
|
-
request_policy:
|
|
116
|
-
response_policy:
|
|
112
|
+
request_policy: parse_policy_tip(row[7], REQUEST_POLICY_PREFIX),
|
|
113
|
+
response_policy: parse_policy_tip(row[7], RESPONSE_POLICY_PREFIX),
|
|
117
114
|
subcommands: parse_subcommands(row[9])
|
|
118
115
|
).freeze
|
|
119
116
|
end
|
|
@@ -137,20 +134,10 @@ class RedisClient
|
|
|
137
134
|
end
|
|
138
135
|
|
|
139
136
|
# The command tips are available in the redis 7.0 or later.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
tips.each do |tip|
|
|
146
|
-
if tip.start_with?(REQUEST_POLICY_PREFIX)
|
|
147
|
-
request_policy = -tip[REQUEST_POLICY_PREFIX.size..]
|
|
148
|
-
elsif tip.start_with?(RESPONSE_POLICY_PREFIX)
|
|
149
|
-
response_policy = -tip[RESPONSE_POLICY_PREFIX.size..]
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
[request_policy, response_policy]
|
|
137
|
+
# It returns a single value instead of a pair to avoid the allocation of the array.
|
|
138
|
+
def parse_policy_tip(tips, prefix)
|
|
139
|
+
tip = tips&.find { |t| t.start_with?(prefix) }
|
|
140
|
+
tip.nil? ? nil : -tip.delete_prefix(prefix)
|
|
154
141
|
end
|
|
155
142
|
|
|
156
143
|
# The information of the subcommands is available in the redis 7.0 or later.
|
|
@@ -164,7 +151,7 @@ class RedisClient
|
|
|
164
151
|
|
|
165
152
|
# The server replies with a full name of the subcommand such as `xinfo|stream`.
|
|
166
153
|
i = name.index(SUBCOMMAND_DELIMITER)
|
|
167
|
-
acc[i.nil? ? name : name[
|
|
154
|
+
acc[i.nil? ? name : name[i + 1, name.size]] = build_spec(row)
|
|
168
155
|
end.freeze
|
|
169
156
|
end
|
|
170
157
|
end
|
|
@@ -26,7 +26,7 @@ class RedisClient
|
|
|
26
26
|
pos = node_key.rindex(DELIMITER, -1)
|
|
27
27
|
return [node_key, nil] if pos.nil?
|
|
28
28
|
|
|
29
|
-
[node_key[0, pos], node_key[
|
|
29
|
+
[node_key[0, pos], node_key[pos + 1, node_key.size]]
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def split_bracketed(node_key)
|
|
@@ -36,7 +36,7 @@ class RedisClient
|
|
|
36
36
|
return nil if end_bracket.nil?
|
|
37
37
|
|
|
38
38
|
host = node_key[1, end_bracket - 1]
|
|
39
|
-
remainder = node_key[
|
|
39
|
+
remainder = node_key[end_bracket + 1, node_key.size]
|
|
40
40
|
port = remainder.start_with?(DELIMITER) ? remainder[1..] : nil
|
|
41
41
|
[host, port]
|
|
42
42
|
end
|