redis 6.0.0 → 6.1.0

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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +114 -0
  3. data/README.md +172 -5
  4. data/lib/redis/client.rb +5 -1
  5. data/lib/redis/commands/arrays.rb +358 -0
  6. data/lib/redis/commands/bitmaps.rb +24 -0
  7. data/lib/redis/commands/bless.rb +115 -0
  8. data/lib/redis/commands/cluster.rb +9 -2
  9. data/lib/redis/commands/hashes.rb +250 -7
  10. data/lib/redis/commands/keys.rb +48 -11
  11. data/lib/redis/commands/modules/json.rb +27 -2
  12. data/lib/redis/commands/modules/search/aggregation.rb +2 -1
  13. data/lib/redis/commands/modules/search/field.rb +11 -2
  14. data/lib/redis/commands/modules/search/hybrid.rb +3 -0
  15. data/lib/redis/commands/modules/search/index.rb +2 -1
  16. data/lib/redis/commands/modules/search/miscellaneous.rb +2 -1
  17. data/lib/redis/commands/modules/search/query.rb +2 -2
  18. data/lib/redis/commands/modules/search/schema.rb +4 -0
  19. data/lib/redis/commands/scripting.rb +109 -0
  20. data/lib/redis/commands/server.rb +158 -7
  21. data/lib/redis/commands/sets.rb +270 -0
  22. data/lib/redis/commands/sorted_sets.rb +131 -6
  23. data/lib/redis/commands/streams.rb +284 -33
  24. data/lib/redis/commands/strings.rb +232 -6
  25. data/lib/redis/commands/transactions.rb +6 -1
  26. data/lib/redis/commands/vector_sets.rb +407 -0
  27. data/lib/redis/commands.rb +169 -6
  28. data/lib/redis/distributed.rb +539 -22
  29. data/lib/redis/hash_ring.rb +2 -1
  30. data/lib/redis/keyspace_notifications/channels.rb +121 -0
  31. data/lib/redis/keyspace_notifications/manager.rb +1121 -0
  32. data/lib/redis/keyspace_notifications/notification.rb +95 -0
  33. data/lib/redis/keyspace_notifications/parser.rb +170 -0
  34. data/lib/redis/keyspace_notifications.rb +59 -0
  35. data/lib/redis/pipeline.rb +17 -5
  36. data/lib/redis/ractorize.rb +6 -0
  37. data/lib/redis/subscribe.rb +80 -2
  38. data/lib/redis/version.rb +1 -1
  39. data/lib/redis/xxh3.rb +354 -0
  40. data/lib/redis.rb +29 -8
  41. metadata +16 -6
data/lib/redis/xxh3.rb ADDED
@@ -0,0 +1,354 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The module below is a direct, function-by-function port of xxHash's XXH3-64
4
+ # (https://github.com/Cyan4973/xxHash, v0.8.3), reproducing its algorithm, constants,
5
+ # and secret table. xxHash is distributed under the following license, reproduced here
6
+ # per its "redistributions of source code must retain" requirement (see LICENSE for
7
+ # this project's own MIT license, which covers everything else in this repository):
8
+ #
9
+ # xxHash Library
10
+ # Copyright (c) 2012-2021 Yann Collet
11
+ # All rights reserved.
12
+ #
13
+ # BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php)
14
+ #
15
+ # Redistribution and use in source and binary forms, with or without modification,
16
+ # are permitted provided that the following conditions are met:
17
+ #
18
+ # * Redistributions of source code must retain the above copyright notice, this
19
+ # list of conditions and the following disclaimer.
20
+ #
21
+ # * Redistributions in binary form must reproduce the above copyright notice, this
22
+ # list of conditions and the following disclaimer in the documentation and/or
23
+ # other materials provided with the distribution.
24
+ #
25
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
29
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
32
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+
36
+ class Redis
37
+ # Pure-Ruby XXH3-64 (unseeded, default secret), matching the Redis server's DIGEST
38
+ # command byte-for-byte. Ported directly, function-by-function, from the reference
39
+ # implementation (https://github.com/Cyan4973/xxHash, v0.8.3 — the same version and
40
+ # secret table the server itself vendors) rather than reimplemented from a description,
41
+ # to avoid subtle per-input-length transcription bugs. Every private method below is
42
+ # named after the upstream C function it mirrors, to keep that mapping checkable.
43
+ #
44
+ # Ships as plain Ruby, no native extension: the 128-bit multiply-and-fold XXH3 needs
45
+ # throughout is the main source of complexity in a C port (no portable 128-bit integer
46
+ # type), but it's trivial with Ruby's native arbitrary-precision integers — `lhs * rhs`
47
+ # never overflows, so the "fold" is just splitting the product with a shift and mask.
48
+ #
49
+ # @example
50
+ # digest = Redis::XXH3.hexdigest("bar")
51
+ # redis.set("foo", "bar")
52
+ # redis.digest("foo") == digest # => true
53
+ module XXH3
54
+ MASK64 = (1 << 64) - 1
55
+ MASK32 = 0xFFFFFFFF
56
+
57
+ PRIME32_1 = 0x9E3779B1
58
+ PRIME32_2 = 0x85EBCA77
59
+ PRIME32_3 = 0xC2B2AE3D
60
+ PRIME64_1 = 0x9E3779B185EBCA87
61
+ PRIME64_2 = 0xC2B2AE3D27D4EB4F
62
+ PRIME64_3 = 0x165667B19E3779F9
63
+ PRIME64_4 = 0x85EBCA77C2B2AE63
64
+ PRIME64_5 = 0x27D4EB2F165667C5
65
+ PRIME_MX1 = 0x165667919E3779F9
66
+ PRIME_MX2 = 0x9FB21C651E98DF25
67
+
68
+ # XXH3_kSecret, verbatim. Not a cryptographic secret: it's a fixed, publicly-known
69
+ # mixing constant from the open-source xxHash reference implementation (the same
70
+ # bytes are in the Redis server's own open-source C source), not a per-installation
71
+ # or per-key value — XXH3 is a non-cryptographic hash and makes no attempt to hide
72
+ # this table. "Secret" is upstream's own name for it, not a claim of confidentiality.
73
+ SECRET = [
74
+ 0xb8, 0xfe, 0x6c, 0x39, 0x23, 0xa4, 0x4b, 0xbe, 0x7c, 0x01, 0x81, 0x2c, 0xf7, 0x21, 0xad, 0x1c,
75
+ 0xde, 0xd4, 0x6d, 0xe9, 0x83, 0x90, 0x97, 0xdb, 0x72, 0x40, 0xa4, 0xa4, 0xb7, 0xb3, 0x67, 0x1f,
76
+ 0xcb, 0x79, 0xe6, 0x4e, 0xcc, 0xc0, 0xe5, 0x78, 0x82, 0x5a, 0xd0, 0x7d, 0xcc, 0xff, 0x72, 0x21,
77
+ 0xb8, 0x08, 0x46, 0x74, 0xf7, 0x43, 0x24, 0x8e, 0xe0, 0x35, 0x90, 0xe6, 0x81, 0x3a, 0x26, 0x4c,
78
+ 0x3c, 0x28, 0x52, 0xbb, 0x91, 0xc3, 0x00, 0xcb, 0x88, 0xd0, 0x65, 0x8b, 0x1b, 0x53, 0x2e, 0xa3,
79
+ 0x71, 0x64, 0x48, 0x97, 0xa2, 0x0d, 0xf9, 0x4e, 0x38, 0x19, 0xef, 0x46, 0xa9, 0xde, 0xac, 0xd8,
80
+ 0xa8, 0xfa, 0x76, 0x3f, 0xe3, 0x9c, 0x34, 0x3f, 0xf9, 0xdc, 0xbb, 0xc7, 0xc7, 0x0b, 0x4f, 0x1d,
81
+ 0x8a, 0x51, 0xe0, 0x4b, 0xcd, 0xb4, 0x59, 0x31, 0xc8, 0x9f, 0x7e, 0xc9, 0xd9, 0x78, 0x73, 0x64,
82
+ 0xea, 0xc5, 0xac, 0x83, 0x34, 0xd3, 0xeb, 0xc3, 0xc5, 0x81, 0xa0, 0xff, 0xfa, 0x13, 0x63, 0xeb,
83
+ 0x17, 0x0d, 0xdd, 0x51, 0xb7, 0xf0, 0xda, 0x49, 0xd3, 0x16, 0x55, 0x26, 0x29, 0xd4, 0x68, 0x9e,
84
+ 0x2b, 0x16, 0xbe, 0x58, 0x7d, 0x47, 0xa1, 0xfc, 0x8f, 0xf8, 0xb8, 0xd1, 0x7a, 0xd0, 0x31, 0xce,
85
+ 0x45, 0xcb, 0x3a, 0x8f, 0x95, 0x16, 0x04, 0x28, 0xaf, 0xd7, 0xfb, 0xca, 0xbb, 0x4b, 0x40, 0x7e
86
+ ].pack("C*").freeze
87
+
88
+ STRIPE_LEN = 64
89
+ SECRET_CONSUME_RATE = 8
90
+ SECRET_SIZE_MIN = 136
91
+ MIDSIZE_MAX = 240
92
+ MIDSIZE_STARTOFFSET = 3
93
+ MIDSIZE_LASTOFFSET = 17
94
+ SECRET_LASTACC_START = 7
95
+ SECRET_MERGEACCS_START = 11
96
+
97
+ # XXH3_INIT_ACC
98
+ INIT_ACC = [PRIME32_3, PRIME64_1, PRIME64_2, PRIME64_3,
99
+ PRIME64_4, PRIME32_2, PRIME64_5, PRIME32_1].freeze
100
+
101
+ # Implementation details of the algorithm, not part of the public API — only
102
+ # Redis::XXH3.hexdigest is meant to be used from outside this module.
103
+ IMPLEMENTATION_CONSTANTS = %i[
104
+ MASK64 MASK32 PRIME32_1 PRIME32_2 PRIME32_3 PRIME64_1 PRIME64_2 PRIME64_3
105
+ PRIME64_4 PRIME64_5 PRIME_MX1 PRIME_MX2 SECRET STRIPE_LEN SECRET_CONSUME_RATE
106
+ SECRET_SIZE_MIN MIDSIZE_MAX MIDSIZE_STARTOFFSET MIDSIZE_LASTOFFSET
107
+ SECRET_LASTACC_START SECRET_MERGEACCS_START INIT_ACC
108
+ ].freeze
109
+ private_constant(*IMPLEMENTATION_CONSTANTS)
110
+ private_constant :IMPLEMENTATION_CONSTANTS
111
+
112
+ class << self
113
+ # @param value [String, #to_s] the value to hash
114
+ # @return [String] 16 lowercase hex characters
115
+ def hexdigest(value)
116
+ format("%016x", hash64(value.to_s.b))
117
+ end
118
+
119
+ private
120
+
121
+ # XXH3_64bits()
122
+ def hash64(input)
123
+ len = input.bytesize
124
+ if len <= 16
125
+ len_0to16_64b(input, len)
126
+ elsif len <= 128
127
+ len_17to128_64b(input, len)
128
+ elsif len <= MIDSIZE_MAX
129
+ len_129to240_64b(input, len)
130
+ else
131
+ hash_long_64b(input, len)
132
+ end
133
+ end
134
+
135
+ def read_le32(str, offset)
136
+ str.unpack1("V", offset: offset)
137
+ end
138
+
139
+ def read_le64(str, offset)
140
+ str.unpack1("Q<", offset: offset)
141
+ end
142
+
143
+ def rotl64(x, r)
144
+ ((x << r) | (x >> (64 - r))) & MASK64
145
+ end
146
+
147
+ # XXH_swap64()
148
+ def swap64(x)
149
+ ((x << 56) & 0xff00000000000000) |
150
+ ((x << 40) & 0x00ff000000000000) |
151
+ ((x << 24) & 0x0000ff0000000000) |
152
+ ((x << 8) & 0x000000ff00000000) |
153
+ ((x >> 8) & 0x00000000ff000000) |
154
+ ((x >> 24) & 0x0000000000ff0000) |
155
+ ((x >> 40) & 0x000000000000ff00) |
156
+ ((x >> 56) & 0x00000000000000ff)
157
+ end
158
+
159
+ # XXH3_mul128_fold64(): 64x64->128 multiply, then XOR-fold the two 64-bit halves.
160
+ def mul128_fold64(lhs, rhs)
161
+ product = lhs * rhs
162
+ (product & MASK64) ^ (product >> 64)
163
+ end
164
+
165
+ def xorshift64(v, shift)
166
+ (v ^ (v >> shift)) & MASK64
167
+ end
168
+
169
+ # XXH3_avalanche()
170
+ def avalanche(h64)
171
+ h64 = xorshift64(h64, 37)
172
+ h64 = (h64 * PRIME_MX1) & MASK64
173
+ xorshift64(h64, 32)
174
+ end
175
+
176
+ # XXH64_avalanche()
177
+ def avalanche64(h)
178
+ h ^= (h >> 33)
179
+ h = (h * PRIME64_2) & MASK64
180
+ h ^= (h >> 29)
181
+ h = (h * PRIME64_3) & MASK64
182
+ h ^= (h >> 32)
183
+ h & MASK64
184
+ end
185
+
186
+ # XXH3_rrmxmx()
187
+ def rrmxmx(h64, len)
188
+ h64 ^= (rotl64(h64, 49) ^ rotl64(h64, 24))
189
+ h64 = (h64 * PRIME_MX2) & MASK64
190
+ h64 ^= ((h64 >> 35) + len)
191
+ h64 = (h64 * PRIME_MX2) & MASK64
192
+ xorshift64(h64, 28)
193
+ end
194
+
195
+ # --- 0-16 bytes: XXH3_len_0to16_64b and its sub-cases (seed is always 0) ---
196
+
197
+ def len_0to16_64b(input, len)
198
+ if len > 8
199
+ len_9to16_64b(input, len)
200
+ elsif len >= 4
201
+ len_4to8_64b(input, len)
202
+ elsif len > 0
203
+ len_1to3_64b(input, len)
204
+ else
205
+ avalanche64(read_le64(SECRET, 56) ^ read_le64(SECRET, 64))
206
+ end
207
+ end
208
+
209
+ # XXH3_len_1to3_64b()
210
+ def len_1to3_64b(input, len)
211
+ c1 = input.getbyte(0)
212
+ c2 = input.getbyte(len >> 1)
213
+ c3 = input.getbyte(len - 1)
214
+ combined = (c1 << 16) | (c2 << 24) | c3 | (len << 8)
215
+ bitflip = read_le32(SECRET, 0) ^ read_le32(SECRET, 4)
216
+ avalanche64((combined ^ bitflip) & MASK64)
217
+ end
218
+
219
+ # XXH3_len_4to8_64b()
220
+ def len_4to8_64b(input, len)
221
+ input1 = read_le32(input, 0)
222
+ input2 = read_le32(input, len - 4)
223
+ bitflip = read_le64(SECRET, 8) ^ read_le64(SECRET, 16)
224
+ input64 = (input2 + (input1 << 32)) & MASK64
225
+ rrmxmx(input64 ^ bitflip, len)
226
+ end
227
+
228
+ # XXH3_len_9to16_64b()
229
+ def len_9to16_64b(input, len)
230
+ bitflip1 = read_le64(SECRET, 24) ^ read_le64(SECRET, 32)
231
+ bitflip2 = read_le64(SECRET, 40) ^ read_le64(SECRET, 48)
232
+ input_lo = read_le64(input, 0) ^ bitflip1
233
+ input_hi = read_le64(input, len - 8) ^ bitflip2
234
+ acc = (len + swap64(input_lo) + input_hi + mul128_fold64(input_lo, input_hi)) & MASK64
235
+ avalanche(acc)
236
+ end
237
+
238
+ # --- 17-128 bytes: XXH3_len_17to128_64b ---
239
+
240
+ # XXH3_mix16B()
241
+ def mix16b(input, input_off, secret_off)
242
+ input_lo = read_le64(input, input_off)
243
+ input_hi = read_le64(input, input_off + 8)
244
+ keyed_lo = input_lo ^ read_le64(SECRET, secret_off)
245
+ keyed_hi = input_hi ^ read_le64(SECRET, secret_off + 8)
246
+ mul128_fold64(keyed_lo, keyed_hi)
247
+ end
248
+
249
+ def len_17to128_64b(input, len)
250
+ acc = (len * PRIME64_1) & MASK64
251
+ if len > 32
252
+ if len > 64
253
+ if len > 96
254
+ acc = (acc + mix16b(input, 48, 96)) & MASK64
255
+ acc = (acc + mix16b(input, len - 64, 112)) & MASK64
256
+ end
257
+ acc = (acc + mix16b(input, 32, 64)) & MASK64
258
+ acc = (acc + mix16b(input, len - 48, 80)) & MASK64
259
+ end
260
+ acc = (acc + mix16b(input, 16, 32)) & MASK64
261
+ acc = (acc + mix16b(input, len - 32, 48)) & MASK64
262
+ end
263
+ acc = (acc + mix16b(input, 0, 0)) & MASK64
264
+ acc = (acc + mix16b(input, len - 16, 16)) & MASK64
265
+ avalanche(acc)
266
+ end
267
+
268
+ # --- 129-240 bytes: XXH3_len_129to240_64b ---
269
+
270
+ def len_129to240_64b(input, len)
271
+ acc = (len * PRIME64_1) & MASK64
272
+ nb_rounds = len / 16
273
+ 8.times { |i| acc = (acc + mix16b(input, 16 * i, 16 * i)) & MASK64 }
274
+ acc = avalanche(acc)
275
+ acc_end = mix16b(input, len - 16, SECRET_SIZE_MIN - MIDSIZE_LASTOFFSET)
276
+ (8...nb_rounds).each do |i|
277
+ acc_end = (acc_end + mix16b(input, 16 * i, (16 * (i - 8)) + MIDSIZE_STARTOFFSET)) & MASK64
278
+ end
279
+ avalanche((acc + acc_end) & MASK64)
280
+ end
281
+
282
+ # --- >240 bytes: XXH3_hashLong_64b_default and its accumulator loop ---
283
+
284
+ def hash_long_64b(input, len)
285
+ acc = INIT_ACC.dup
286
+ hash_long_internal_loop(acc, input, len)
287
+ finalize_long_64b(acc, len)
288
+ end
289
+
290
+ # XXH3_hashLong_internal_loop()
291
+ def hash_long_internal_loop(acc, input, len)
292
+ secret_size = SECRET.bytesize
293
+ nb_stripes_per_block = (secret_size - STRIPE_LEN) / SECRET_CONSUME_RATE
294
+ block_len = STRIPE_LEN * nb_stripes_per_block
295
+ nb_blocks = (len - 1) / block_len
296
+
297
+ nb_blocks.times do |n|
298
+ accumulate(acc, input, n * block_len, nb_stripes_per_block)
299
+ scramble_acc(acc, secret_size - STRIPE_LEN)
300
+ end
301
+
302
+ nb_stripes = ((len - 1) - (block_len * nb_blocks)) / STRIPE_LEN
303
+ accumulate(acc, input, nb_blocks * block_len, nb_stripes)
304
+
305
+ # last stripe
306
+ accumulate_512(acc, input, len - STRIPE_LEN, secret_size - STRIPE_LEN - SECRET_LASTACC_START)
307
+ end
308
+
309
+ # XXH3_accumulate_scalar()
310
+ def accumulate(acc, input, input_off, nb_stripes)
311
+ nb_stripes.times do |n|
312
+ accumulate_512(acc, input, input_off + (n * STRIPE_LEN), n * SECRET_CONSUME_RATE)
313
+ end
314
+ end
315
+
316
+ # XXH3_accumulate_512_scalar() / XXH3_scalarRound(): mutates `acc` (8 lanes) in place;
317
+ # lane order matters since each round writes both acc[lane] and acc[lane ^ 1].
318
+ def accumulate_512(acc, input, input_off, secret_off)
319
+ 8.times do |lane|
320
+ data_val = read_le64(input, input_off + (lane * 8))
321
+ data_key = data_val ^ read_le64(SECRET, secret_off + (lane * 8))
322
+ acc[lane ^ 1] = (acc[lane ^ 1] + data_val) & MASK64
323
+ acc[lane] = (((data_key & MASK32) * ((data_key >> 32) & MASK32)) + acc[lane]) & MASK64
324
+ end
325
+ end
326
+
327
+ # XXH3_scrambleAcc_scalar() / XXH3_scalarScrambleRound()
328
+ def scramble_acc(acc, secret_off)
329
+ 8.times do |lane|
330
+ key64 = read_le64(SECRET, secret_off + (lane * 8))
331
+ acc64 = xorshift64(acc[lane], 47)
332
+ acc64 ^= key64
333
+ acc[lane] = (acc64 * PRIME32_1) & MASK64
334
+ end
335
+ end
336
+
337
+ # XXH3_finalizeLong_64b()
338
+ def finalize_long_64b(acc, len)
339
+ merge_accs(acc, SECRET_MERGEACCS_START, (len * PRIME64_1) & MASK64)
340
+ end
341
+
342
+ # XXH3_mergeAccs() / XXH3_mix2Accs()
343
+ def merge_accs(acc, secret_off, start)
344
+ result = start
345
+ 4.times do |i|
346
+ lo = acc[2 * i] ^ read_le64(SECRET, secret_off + (16 * i))
347
+ hi = acc[(2 * i) + 1] ^ read_le64(SECRET, secret_off + (16 * i) + 8)
348
+ result = (result + mul128_fold64(lo, hi)) & MASK64
349
+ end
350
+ avalanche(result)
351
+ end
352
+ end
353
+ end
354
+ end
data/lib/redis.rb CHANGED
@@ -7,7 +7,7 @@ require "redis/errors"
7
7
  require "redis/commands"
8
8
 
9
9
  class Redis
10
- BASE_PATH = __dir__
10
+ BASE_PATH = __dir__.freeze
11
11
  Deprecated = Class.new(StandardError)
12
12
 
13
13
  class << self
@@ -64,6 +64,11 @@ class Redis
64
64
  # @option options [Integer, Array<Integer, Float>] :reconnect_attempts Number of attempts trying to connect,
65
65
  # or a list of sleep duration between attempts.
66
66
  # @option options [Boolean] :inherit_socket (false) Whether to use socket in forked process or not
67
+ # @option options [Boolean] :himport_auto_prepare (true) Whether to automatically re-prepare a
68
+ # `HIMPORT` fieldset and retry the `himport_set` once when the server reports the fieldset was
69
+ # lost (reconnect, failover, `RESET`). When `false`, the error is raised to the caller, who is
70
+ # responsible for retaining the schema and calling `himport_prepare` again. See the README
71
+ # "Bulk hash ingestion (HIMPORT)" section.
67
72
  # @option options [String] :name The name of the server group to connect to.
68
73
  # @option options [Array] :sentinels List of sentinels to contact
69
74
  #
@@ -123,9 +128,12 @@ class Redis
123
128
  def pipelined(exception: true)
124
129
  synchronize do |client|
125
130
  client.pipelined(exception: exception) do |raw_pipeline|
126
- yield PipelinedConnection.new(raw_pipeline, exception: exception)
131
+ yield PipelinedConnection.new(raw_pipeline, client: client, exception: exception)
127
132
  end
128
133
  end
134
+ rescue ::RedisClient::Error => error
135
+ # With sentinels, @client is a plain RedisClient that doesn't translate its own errors.
136
+ Client.translate_error!(error)
129
137
  end
130
138
 
131
139
  def id
@@ -136,11 +144,15 @@ class Redis
136
144
  "#<Redis client v#{Redis::VERSION} for #{id}>"
137
145
  end
138
146
 
139
- def dup
147
+ def dup(**option_overrides)
140
148
  # inherit_socket and himport_auto_prepare are stripped from @options before the client config
141
149
  # is built (RedisClient::Config doesn't know them); merge the live values back so the
142
150
  # duplicate keeps the caller's settings instead of silently reverting to defaults.
143
- self.class.new(@options.merge(inherit_socket: @inherit_socket, himport_auto_prepare: @himport_auto_prepare))
151
+ # Explicit overrides win — keyspace_notifications relies on this to disable transport
152
+ # retries on the connection its manager owns.
153
+ self.class.new(@options.merge(inherit_socket: @inherit_socket,
154
+ himport_auto_prepare: @himport_auto_prepare,
155
+ **option_overrides))
144
156
  end
145
157
 
146
158
  def connection
@@ -160,7 +172,9 @@ class Redis
160
172
  # session was lost. These overrides remember the last schema prepared per fieldset name and,
161
173
  # on that error, re-prepare it and retry the SET exactly once. An explicitly discarded
162
174
  # fieldset is removed from the registry and is never resurrected. Disable the recovery with
163
- # `Redis.new(himport_auto_prepare: false)`; the registry is still recorded for manual use.
175
+ # `Redis.new(himport_auto_prepare: false)`: the loss error then propagates, and re-preparing is
176
+ # the caller's responsibility — the registry is internal state with no public reader, so callers
177
+ # must retain their schemas themselves.
164
178
 
165
179
  # Each method holds @monitor across the server command AND its registry mutation: the two must
166
180
  # be atomic with respect to other threads, otherwise a himport_set failing between another
@@ -170,9 +184,10 @@ class Redis
170
184
 
171
185
  def himport_prepare(fieldset_name, *fields)
172
186
  fields.flatten!(1)
187
+ fields.map! { |field| field.dup.freeze }
173
188
  @monitor.synchronize do
174
189
  reply = super(fieldset_name, fields)
175
- @himport_fieldsets[fieldset_name.to_s] = fields.dup.freeze
190
+ @himport_fieldsets[fieldset_name.to_s] = fields.freeze
176
191
  reply
177
192
  end
178
193
  end
@@ -310,11 +325,15 @@ class Redis
310
325
  @subscription_client = nil
311
326
  end
312
327
  else
313
- unless @subscription_client
328
+ # Capture before use: the subscribed thread's teardown nils the ivar
329
+ # concurrently, and reading it twice would turn that race into a
330
+ # NoMethodError on nil instead of the SubscriptionError callers handle.
331
+ client = @subscription_client
332
+ unless client
314
333
  raise SubscriptionError, "This client is not subscribed"
315
334
  end
316
335
 
317
- @subscription_client.call_v([method].concat(channels))
336
+ client.call_v([method].concat(channels))
318
337
  end
319
338
  end
320
339
  end
@@ -324,3 +343,5 @@ require "redis/lib_identity"
324
343
  require "redis/client"
325
344
  require "redis/pipeline"
326
345
  require "redis/subscribe"
346
+ require "redis/keyspace_notifications"
347
+ require "redis/xxh3"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezra Zygmuntowicz
@@ -15,7 +15,7 @@ authors:
15
15
  - Pieter Noordhuis
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2026-07-31 00:00:00.000000000 Z
18
+ date: 2026-11-23 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: redis-client
@@ -23,14 +23,14 @@ dependencies:
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.30.1
26
+ version: 0.31.0
27
27
  type: :runtime
28
28
  prerelease: false
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.30.1
33
+ version: 0.31.0
34
34
  description: |2
35
35
  A Ruby client that tries to match Redis' API one-to-one, while still
36
36
  providing an idiomatic interface.
@@ -46,7 +46,9 @@ files:
46
46
  - lib/redis.rb
47
47
  - lib/redis/client.rb
48
48
  - lib/redis/commands.rb
49
+ - lib/redis/commands/arrays.rb
49
50
  - lib/redis/commands/bitmaps.rb
51
+ - lib/redis/commands/bless.rb
50
52
  - lib/redis/commands/cluster.rb
51
53
  - lib/redis/commands/connection.rb
52
54
  - lib/redis/commands/geo.rb
@@ -74,22 +76,30 @@ files:
74
76
  - lib/redis/commands/streams.rb
75
77
  - lib/redis/commands/strings.rb
76
78
  - lib/redis/commands/transactions.rb
79
+ - lib/redis/commands/vector_sets.rb
77
80
  - lib/redis/distributed.rb
78
81
  - lib/redis/errors.rb
79
82
  - lib/redis/hash_ring.rb
83
+ - lib/redis/keyspace_notifications.rb
84
+ - lib/redis/keyspace_notifications/channels.rb
85
+ - lib/redis/keyspace_notifications/manager.rb
86
+ - lib/redis/keyspace_notifications/notification.rb
87
+ - lib/redis/keyspace_notifications/parser.rb
80
88
  - lib/redis/lib_identity.rb
81
89
  - lib/redis/pipeline.rb
90
+ - lib/redis/ractorize.rb
82
91
  - lib/redis/subscribe.rb
83
92
  - lib/redis/version.rb
93
+ - lib/redis/xxh3.rb
84
94
  homepage: https://github.com/redis/redis-rb
85
95
  licenses:
86
96
  - MIT
87
97
  metadata:
88
98
  bug_tracker_uri: https://github.com/redis/redis-rb/issues
89
99
  changelog_uri: https://github.com/redis/redis-rb/blob/master/CHANGELOG.md
90
- documentation_uri: https://www.rubydoc.info/gems/redis/6.0.0
100
+ documentation_uri: https://www.rubydoc.info/gems/redis/6.1.0
91
101
  homepage_uri: https://github.com/redis/redis-rb
92
- source_code_uri: https://github.com/redis/redis-rb/tree/v6.0.0
102
+ source_code_uri: https://github.com/redis/redis-rb/tree/v6.1.0
93
103
  rdoc_options: []
94
104
  require_paths:
95
105
  - lib