redis 5.0.0.beta4 → 5.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 94568e707734a9e2f7c90aa599174444c27313d30e877b74f5989d50b60e31cf
4
- data.tar.gz: cf1ce567caae9928ba4d9902b26621e83a44ee8c4989420df9e5616684970cfb
3
+ metadata.gz: 15a91a0ef8a3f697bc35cb5c4029d979134b58984b7c23deee36707cfc081a32
4
+ data.tar.gz: 9cdb4881111253801c3f1ad5a4f5fafa38b14b384ba595bbc422fa899d006619
5
5
  SHA512:
6
- metadata.gz: 36d2cf7667a6c94b575e0e20074e088982c2fafc070ef42885b00207298d2814b5045e1eeae6cd12d971e0054fa86181d03f3ad0a2b044cfd4e40c4ac9c93852
7
- data.tar.gz: 1208702dde8518adf21a497b75613824167526d3ddd1c99dda6ae06a319081b7d3473d83183cc76623008043e17c3bc206da1b86d89e9108c004c6fbadc34994
6
+ metadata.gz: 69731342edc1c5d5b26ce18deecac7c3b4d1a2b452272df977ae3ccb5cd5812174ebdbb1a78b19e96d6ccf8e45a0256e46a927ad1a2a7a9577c08eb35055e800
7
+ data.tar.gz: f9994ab4b694c99862ba932795c842c5fa24d72790ee44e908162e144608c481f2052aa2af6cca42d173b77af3e8a5a9d90dffcaf828f3a818dc1196fe4aa590
data/CHANGELOG.md CHANGED
@@ -1,17 +1,22 @@
1
1
  # Unreleased
2
2
 
3
- # 5.0.0.beta4
3
+ # 5.0.2
4
4
 
5
- - Allow to call `subscribe`, `unsubscribe`, `psubscribe` and `punsubscribe` from a subscribed client. See #1131.
6
- - Fix `redis-clustering` gem to specify the dependency on `redis`
5
+ - Fix `Redis#close` to properly reset the fork protection check.
6
+
7
+ # 5.0.1
8
+
9
+ - Added a fake `Redis::Connections.drivers` method to be compatible with older sidekiq versions.
7
10
 
8
- # 5.0.0.beta3
11
+ # 5.0.0
9
12
 
13
+ - Eagerly and strictly cast Integer and Float parameters.
14
+ - Allow to call `subscribe`, `unsubscribe`, `psubscribe` and `punsubscribe` from a subscribed client. See #1131.
10
15
  - Use `MD5` for hashing server nodes in `Redis::Distributed`. This should improve keys distribution among servers. See #1089.
11
16
  - Changed `sadd` and `srem` to now always return an Integer.
12
17
  - Added `sadd?` and `srem?` which always return a Boolean.
13
18
  - Added support for `IDLE` paramter in `xpending`.
14
- - Cluster support has been moved to a `rediscluster` companion gem.
19
+ - Cluster support has been moved to a `redis-clustering` companion gem.
15
20
  - `select` no longer record the current database. If the client has to reconnect after `select` was used, it will reconnect to the original database.
16
21
  - Better support Float timeout in blocking commands. See #977.
17
22
  - Removed positional timeout in blocking commands (`BLPOP`, etc). Timeout now must be passed as an option: `r.blpop("key", timeout: 2.5)`
@@ -26,6 +31,13 @@
26
31
  - Removed the `synchrony` driver.
27
32
  - Removed `Redis.exists_returns_integer`, it's now always enabled.
28
33
 
34
+ # 4.8.0
35
+
36
+ * Introduce `sadd?` and `srem?` as boolean returning versions of `sadd` and `srem`.
37
+ * Deprecate `sadd` and `srem` returning a boolean when called with a single argument.
38
+ To enable the redis 5.0 behavior you can set `Redis.sadd_returns_boolean = true`.
39
+ * Deprecate passing `timeout` as a positional argument in blocking commands (`brpop`, `blop`, etc).
40
+
29
41
  # 4.7.1
30
42
 
31
43
  * Gracefully handle OpenSSL 3.0 EOF Errors (`OpenSSL::SSL::SSLError: SSL_read: unexpected eof while reading`). See #1106
data/README.md CHANGED
@@ -77,7 +77,7 @@ The client does not provide connection pooling. Each `Redis` instance
77
77
  has one and only one connection to the server, and use of this connection
78
78
  is protected by a mutex.
79
79
 
80
- As such it is heavilly recommended to use the [`connection_pool` gem], e.g.:
80
+ As such it is heavilly recommended to use the [`connection_pool` gem](https://github.com/mperham/connection_pool), e.g.:
81
81
 
82
82
  ```ruby
83
83
  module MyApp
@@ -91,8 +91,6 @@ end
91
91
  MyApp.redis.incr("some-counter")
92
92
  ```
93
93
 
94
- [`connection_pool` gem](https://github.com/mperham/connection_pool)
95
-
96
94
  ## Sentinel support
97
95
 
98
96
  The client is able to perform automatic failover by using [Redis
@@ -157,7 +155,7 @@ end
157
155
  ```
158
156
 
159
157
  Commands must be called on the yielded objects. If you call methods
160
- on the original client objects from inside a pipeline, they willb e sent immediately:
158
+ on the original client objects from inside a pipeline, they will be sent immediately:
161
159
 
162
160
  ```ruby
163
161
  redis.pipelined do |pipeline|
data/lib/redis/client.rb CHANGED
@@ -30,7 +30,7 @@ class Redis
30
30
  def initialize(*)
31
31
  super
32
32
  @inherit_socket = false
33
- @pid = Process.pid
33
+ @pid = nil
34
34
  end
35
35
  ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true)
36
36
 
@@ -114,10 +114,15 @@ class Redis
114
114
  @inherit_socket = true
115
115
  end
116
116
 
117
+ def close
118
+ super
119
+ @pid = nil
120
+ end
121
+
117
122
  private
118
123
 
119
124
  def ensure_connected(retryable: true)
120
- unless @inherit_socket || Process.pid == @pid
125
+ unless @inherit_socket || (@pid ||= Process.pid) == Process.pid
121
126
  raise InheritedError,
122
127
  "Tried to use a connection from a child process without reconnecting. " \
123
128
  "You need to reconnect to Redis after forking " \
@@ -74,9 +74,9 @@ class Redis
74
74
  private
75
75
 
76
76
  def _geoarguments(*args, options: nil, sort: nil, count: nil)
77
- args.push sort if sort
78
- args.push 'count', count if count
79
- args.push options if options
77
+ args << sort if sort
78
+ args << 'COUNT' << Integer(count) if count
79
+ args << options if options
80
80
  args
81
81
  end
82
82
  end
@@ -174,7 +174,7 @@ class Redis
174
174
  # @param [Integer] increment
175
175
  # @return [Integer] value of the field after incrementing it
176
176
  def hincrby(key, field, increment)
177
- send_command([:hincrby, key, field, increment])
177
+ send_command([:hincrby, key, field, Integer(increment)])
178
178
  end
179
179
 
180
180
  # Increment the numeric value of a hash field by the given float number.
@@ -184,7 +184,7 @@ class Redis
184
184
  # @param [Float] increment
185
185
  # @return [Float] value of the field after incrementing it
186
186
  def hincrbyfloat(key, field, increment)
187
- send_command([:hincrbyfloat, key, field, increment], &Floatify)
187
+ send_command([:hincrbyfloat, key, field, Float(increment)], &Floatify)
188
188
  end
189
189
 
190
190
  # Get all the fields in a hash.
@@ -427,7 +427,7 @@ class Redis
427
427
 
428
428
  args << cursor
429
429
  args << "MATCH" << match if match
430
- args << "COUNT" << count if count
430
+ args << "COUNT" << Integer(count) if count
431
431
  args << "TYPE" << type if type
432
432
 
433
433
  send_command([command] + args, &block)
@@ -99,10 +99,10 @@ class Redis
99
99
  #
100
100
  # @param [String] key
101
101
  # @param [Integer] count number of elements to remove
102
- # @return [String, Array<String>] the values of the first elements
102
+ # @return [nil, String, Array<String>] the values of the first elements
103
103
  def lpop(key, count = nil)
104
104
  command = [:lpop, key]
105
- command << count if count
105
+ command << Integer(count) if count
106
106
  send_command(command)
107
107
  end
108
108
 
@@ -110,10 +110,10 @@ class Redis
110
110
  #
111
111
  # @param [String] key
112
112
  # @param [Integer] count number of elements to remove
113
- # @return [String, Array<String>] the values of the last elements
113
+ # @return [nil, String, Array<String>] the values of the last elements
114
114
  def rpop(key, count = nil)
115
115
  command = [:rpop, key]
116
- command << count if count
116
+ command << Integer(count) if count
117
117
  send_command(command)
118
118
  end
119
119
 
@@ -189,7 +189,7 @@ class Redis
189
189
  # @param [Integer] index
190
190
  # @return [String]
191
191
  def lindex(key, index)
192
- send_command([:lindex, key, index])
192
+ send_command([:lindex, key, Integer(index)])
193
193
  end
194
194
 
195
195
  # Insert an element before or after another element in a list.
@@ -211,7 +211,7 @@ class Redis
211
211
  # @param [Integer] stop stop index
212
212
  # @return [Array<String>]
213
213
  def lrange(key, start, stop)
214
- send_command([:lrange, key, start, stop])
214
+ send_command([:lrange, key, Integer(start), Integer(stop)])
215
215
  end
216
216
 
217
217
  # Remove elements from a list.
@@ -224,7 +224,7 @@ class Redis
224
224
  # @param [String] value
225
225
  # @return [Integer] the number of removed elements
226
226
  def lrem(key, count, value)
227
- send_command([:lrem, key, count, value])
227
+ send_command([:lrem, key, Integer(count), value])
228
228
  end
229
229
 
230
230
  # Set the value of an element in a list by its index.
@@ -234,7 +234,7 @@ class Redis
234
234
  # @param [String] value
235
235
  # @return [String] `OK`
236
236
  def lset(key, index, value)
237
- send_command([:lset, key, index, value])
237
+ send_command([:lset, key, Integer(index), value])
238
238
  end
239
239
 
240
240
  # Trim a list to the specified range.
@@ -244,7 +244,7 @@ class Redis
244
244
  # @param [Integer] stop stop index
245
245
  # @return [String] `OK`
246
246
  def ltrim(key, start, stop)
247
- send_command([:ltrim, key, start, stop])
247
+ send_command([:ltrim, key, Integer(start), Integer(stop)])
248
248
  end
249
249
 
250
250
  private
@@ -36,7 +36,7 @@ class Redis
36
36
  #
37
37
  # @param [String, Symbol] subcommand e.g. `kill`, `list`, `getname`, `setname`
38
38
  # @return [String, Hash] depends on subcommand
39
- def client(subcommand = nil, *args)
39
+ def client(subcommand, *args)
40
40
  send_command([:client, subcommand] + args) do |reply|
41
41
  if subcommand.to_s == "list"
42
42
  reply.lines.map do |line|
@@ -158,7 +158,7 @@ class Redis
158
158
  # @return [Array<String>, Integer, String] depends on subcommand
159
159
  def slowlog(subcommand, length = nil)
160
160
  args = [:slowlog, subcommand]
161
- args << length if length
161
+ args << Integer(length) if length
162
162
  send_command(args)
163
163
  end
164
164
 
@@ -60,7 +60,7 @@ class Redis
60
60
  if count.nil?
61
61
  send_command([:spop, key])
62
62
  else
63
- send_command([:spop, key, count])
63
+ send_command([:spop, key, Integer(count)])
64
64
  end
65
65
  end
66
66
 
@@ -136,7 +136,9 @@ class Redis
136
136
  # @return [Array<String, Float>] element and score pair if count is not specified
137
137
  # @return [Array<Array<String, Float>>] list of popped elements and scores
138
138
  def zpopmax(key, count = nil)
139
- send_command([:zpopmax, key, count].compact) do |members|
139
+ command = [:zpopmax, key]
140
+ command << Integer(count) if count
141
+ send_command(command) do |members|
140
142
  members = FloatifyPairs.call(members)
141
143
  count.to_i > 1 ? members : members.first
142
144
  end
@@ -157,7 +159,9 @@ class Redis
157
159
  # @return [Array<String, Float>] element and score pair if count is not specified
158
160
  # @return [Array<Array<String, Float>>] list of popped elements and scores
159
161
  def zpopmin(key, count = nil)
160
- send_command([:zpopmin, key, count].compact) do |members|
162
+ command = [:zpopmin, key]
163
+ command << Integer(count) if count
164
+ send_command(command) do |members|
161
165
  members = FloatifyPairs.call(members)
162
166
  count.to_i > 1 ? members : members.first
163
167
  end
@@ -261,7 +265,7 @@ class Redis
261
265
  end
262
266
 
263
267
  args = [:zrandmember, key]
264
- args << count if count
268
+ args << Integer(count) if count
265
269
 
266
270
  if with_scores
267
271
  args << "WITHSCORES"
@@ -313,7 +317,7 @@ class Redis
313
317
 
314
318
  if limit
315
319
  args << "LIMIT"
316
- args.concat(limit)
320
+ args.concat(limit.map { |l| Integer(l) })
317
321
  end
318
322
 
319
323
  if with_scores
@@ -354,7 +358,7 @@ class Redis
354
358
 
355
359
  if limit
356
360
  args << "LIMIT"
357
- args.concat(limit)
361
+ args.concat(limit.map { |l| Integer(l) })
358
362
  end
359
363
 
360
364
  send_command(args)
@@ -372,7 +376,7 @@ class Redis
372
376
  #
373
377
  # @see #zrange
374
378
  def zrevrange(key, start, stop, withscores: false, with_scores: withscores)
375
- args = [:zrevrange, key, start, stop]
379
+ args = [:zrevrange, key, Integer(start), Integer(stop)]
376
380
 
377
381
  if with_scores
378
382
  args << "WITHSCORES"
@@ -466,7 +470,7 @@ class Redis
466
470
 
467
471
  if limit
468
472
  args << "LIMIT"
469
- args.concat(limit)
473
+ args.concat(limit.map { |l| Integer(l) })
470
474
  end
471
475
 
472
476
  send_command(args)
@@ -488,7 +492,7 @@ class Redis
488
492
 
489
493
  if limit
490
494
  args << "LIMIT"
491
- args.concat(limit)
495
+ args.concat(limit.map { |l| Integer(l) })
492
496
  end
493
497
 
494
498
  send_command(args)
@@ -531,7 +535,7 @@ class Redis
531
535
 
532
536
  if limit
533
537
  args << "LIMIT"
534
- args.concat(limit)
538
+ args.concat(limit.map { |l| Integer(l) })
535
539
  end
536
540
 
537
541
  send_command(args, &block)
@@ -561,7 +565,7 @@ class Redis
561
565
 
562
566
  if limit
563
567
  args << "LIMIT"
564
- args.concat(limit)
568
+ args.concat(limit.map { |l| Integer(l) })
565
569
  end
566
570
 
567
571
  send_command(args, &block)
@@ -25,7 +25,7 @@ class Redis
25
25
  # @param [Integer] decrement
26
26
  # @return [Integer] value after decrementing it
27
27
  def decrby(key, decrement)
28
- send_command([:decrby, key, decrement])
28
+ send_command([:decrby, key, Integer(decrement)])
29
29
  end
30
30
 
31
31
  # Increment the integer value of a key by one.
@@ -50,7 +50,7 @@ class Redis
50
50
  # @param [Integer] increment
51
51
  # @return [Integer] value after incrementing it
52
52
  def incrby(key, increment)
53
- send_command([:incrby, key, increment])
53
+ send_command([:incrby, key, Integer(increment)])
54
54
  end
55
55
 
56
56
  # Increment the numeric value of a key by the given float number.
@@ -63,7 +63,7 @@ class Redis
63
63
  # @param [Float] increment
64
64
  # @return [Float] value after incrementing it
65
65
  def incrbyfloat(key, increment)
66
- send_command([:incrbyfloat, key, increment], &Floatify)
66
+ send_command([:incrbyfloat, key, Float(increment)], &Floatify)
67
67
  end
68
68
 
69
69
  # Set the string value of a key.
@@ -82,10 +82,10 @@ class Redis
82
82
  # @return [String, Boolean] `"OK"` or true, false if `:nx => true` or `:xx => true`
83
83
  def set(key, value, ex: nil, px: nil, exat: nil, pxat: nil, nx: nil, xx: nil, keepttl: nil, get: nil)
84
84
  args = [:set, key, value.to_s]
85
- args << "EX" << ex if ex
86
- args << "PX" << px if px
87
- args << "EXAT" << exat if exat
88
- args << "PXAT" << pxat if pxat
85
+ args << "EX" << Integer(ex) if ex
86
+ args << "PX" << Integer(px) if px
87
+ args << "EXAT" << Integer(exat) if exat
88
+ args << "PXAT" << Integer(pxat) if pxat
89
89
  args << "NX" if nx
90
90
  args << "XX" if xx
91
91
  args << "KEEPTTL" if keepttl
@@ -233,7 +233,7 @@ class Redis
233
233
  # @param [String] value
234
234
  # @return [Integer] length of the string after it was modified
235
235
  def setrange(key, offset, value)
236
- send_command([:setrange, key, offset, value.to_s])
236
+ send_command([:setrange, key, Integer(offset), value.to_s])
237
237
  end
238
238
 
239
239
  # Get a substring of the string stored at a key.
@@ -244,7 +244,7 @@ class Redis
244
244
  # the end of the string
245
245
  # @return [Integer] `0` or `1`
246
246
  def getrange(key, start, stop)
247
- send_command([:getrange, key, start, stop])
247
+ send_command([:getrange, key, Integer(start), Integer(stop)])
248
248
  end
249
249
 
250
250
  # Append a value to a key.
@@ -292,10 +292,10 @@ class Redis
292
292
  # @return [String] The value of key, or nil when key does not exist.
293
293
  def getex(key, ex: nil, px: nil, exat: nil, pxat: nil, persist: false)
294
294
  args = [:getex, key]
295
- args << "EX" << ex if ex
296
- args << "PX" << px if px
297
- args << "EXAT" << exat if exat
298
- args << "PXAT" << pxat if pxat
295
+ args << "EX" << Integer(ex) if ex
296
+ args << "PX" << Integer(px) if px
297
+ args << "EXAT" << Integer(exat) if exat
298
+ args << "PXAT" << Integer(pxat) if pxat
299
299
  args << "PERSIST" if persist
300
300
 
301
301
  send_command(args)
data/lib/redis/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Redis
4
- VERSION = '5.0.0.beta4'
4
+ VERSION = '5.0.2'
5
5
  end
data/lib/redis.rb CHANGED
@@ -22,6 +22,16 @@ class Redis
22
22
  end
23
23
  end
24
24
 
25
+ # soft-deprecated
26
+ # We added this back for older sidekiq releases
27
+ module Connection
28
+ class << self
29
+ def drivers
30
+ [RedisClient.default_driver]
31
+ end
32
+ end
33
+ end
34
+
25
35
  include Commands
26
36
 
27
37
  SERVER_URL_OPTIONS = %i(url host port path).freeze
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: 5.0.0.beta4
4
+ version: 5.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ezra Zygmuntowicz
@@ -16,7 +16,7 @@ authors:
16
16
  autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
- date: 2022-08-19 00:00:00.000000000 Z
19
+ date: 2022-08-31 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: redis-client
@@ -75,9 +75,9 @@ licenses:
75
75
  metadata:
76
76
  bug_tracker_uri: https://github.com/redis/redis-rb/issues
77
77
  changelog_uri: https://github.com/redis/redis-rb/blob/master/CHANGELOG.md
78
- documentation_uri: https://www.rubydoc.info/gems/redis/5.0.0.beta4
78
+ documentation_uri: https://www.rubydoc.info/gems/redis/5.0.2
79
79
  homepage_uri: https://github.com/redis/redis-rb
80
- source_code_uri: https://github.com/redis/redis-rb/tree/v5.0.0.beta4
80
+ source_code_uri: https://github.com/redis/redis-rb/tree/v5.0.2
81
81
  post_install_message:
82
82
  rdoc_options: []
83
83
  require_paths:
@@ -89,9 +89,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  version: 2.5.0
90
90
  required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - ">"
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
- version: 1.3.1
94
+ version: '0'
95
95
  requirements: []
96
96
  rubygems_version: 3.1.2
97
97
  signing_key: