redis 5.0.5 → 5.0.6

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: 1b7a13649e5ef98d3c804d2d56d62831fd9b23c83c87c40786a95d812f9dfbbd
4
- data.tar.gz: eebfce4b4f01428a2fbd8cb476b007a0d0c5bfc1c168ca90aa4ea8dbbbe8d633
3
+ metadata.gz: 7b000349da8b2f7ae8ed14909175306d2c719a9873bf1dabe05c4719ae96d0da
4
+ data.tar.gz: fdcda2f50f9d33265f7ba24d3f29a2e078fabe5240e1eaf01efae51e0b83eb0b
5
5
  SHA512:
6
- metadata.gz: ea3d51ea955613bc695040eca6b6925bb82bc7eb32e19afc7999cf9bbfdb8c794884b6a60633e05ced2343ecc203c90d40c0af7d76c76bbab57d8844114bc015
7
- data.tar.gz: 9d50a2d93891fd508409c3517aeb23f204dbc53a6586758e06d06875e701d4d871e2e6c54b0c0aba9f1b58b00735c1a8b6e6bffb86b5fc48a2ca48d4165a0636
6
+ metadata.gz: 990972ebefe548f952cbf630708298f52c1856fa5a142a341f2548bd9173f03f0106d6b745c7e39cc5baa9f084d5fea5e4c0bf42cf1d42df94e404f3558d7816
7
+ data.tar.gz: e52615e0d5b7ca9d554ffc540fdfec524d2aed74ac1c7fc3c727d3096504aa81ff43a85b9e2ce7b21da87edf21ca5f92197171ff1b1c62fa85c7551839e9df83
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Unreleased
2
2
 
3
+ # 5.0.6
4
+
5
+ - Wait for an extra `config.read_timeout` in blocking commands rather than an arbitrary 100ms. See #1175.
6
+ - Treat ReadOnlyError as ConnectionError. See #1168.
7
+
3
8
  # 5.0.5
4
9
 
5
10
  - Fix automatic disconnection when the process was forked. See #1157.
@@ -31,6 +36,7 @@
31
36
  - Cluster support has been moved to a `redis-clustering` companion gem.
32
37
  - `select` no longer record the current database. If the client has to reconnect after `select` was used, it will reconnect to the original database.
33
38
  - Better support Float timeout in blocking commands. See #977.
39
+ - `Redis.new` will now raise an error if provided unknown options.
34
40
  - Removed positional timeout in blocking commands (`BLPOP`, etc). Timeout now must be passed as an option: `r.blpop("key", timeout: 2.5)`
35
41
  - Removed `logger` option.
36
42
  - Removed `reconnect_delay_max` and `reconnect_delay`, you can pass precise sleep durations to `reconnect_attempts` instead.
data/lib/redis/client.rb CHANGED
@@ -78,9 +78,9 @@ class Redis
78
78
  def blocking_call_v(timeout, command, &block)
79
79
  if timeout && timeout > 0
80
80
  # Can't use the command timeout argument as the connection timeout
81
- # otherwise it would be very racy. So we add an extra 100ms to account for
82
- # the network delay.
83
- timeout += 0.1
81
+ # otherwise it would be very racy. So we add the regular read_timeout on top
82
+ # to account for the network delay.
83
+ timeout += config.read_timeout
84
84
  end
85
85
 
86
86
  super(timeout, command, &block)
@@ -34,7 +34,7 @@ class Redis
34
34
  # @example Without options
35
35
  # redis.xadd('mystream', f1: 'v1', f2: 'v2')
36
36
  # @example With options
37
- # redis.xadd('mystream', { f1: 'v1', f2: 'v2' }, id: '0-0', maxlen: 1000, approximate: true)
37
+ # redis.xadd('mystream', { f1: 'v1', f2: 'v2' }, id: '0-0', maxlen: 1000, approximate: true, nomkstream: true)
38
38
  #
39
39
  # @param key [String] the stream key
40
40
  # @param entry [Hash] one or multiple field-value pairs
@@ -43,10 +43,12 @@ class Redis
43
43
  # @option opts [String] :id the entry id, default value is `*`, it means auto generation
44
44
  # @option opts [Integer] :maxlen max length of entries
45
45
  # @option opts [Boolean] :approximate whether to add `~` modifier of maxlen or not
46
+ # @option opts [Boolean] :nomkstream whether to add NOMKSTREAM, default is not to add
46
47
  #
47
48
  # @return [String] the entry id
48
- def xadd(key, entry, approximate: nil, maxlen: nil, id: '*')
49
+ def xadd(key, entry, approximate: nil, maxlen: nil, nomkstream: nil, id: '*')
49
50
  args = [:xadd, key]
51
+ args << 'NOMKSTREAM' if nomkstream
50
52
  if maxlen
51
53
  args << "MAXLEN"
52
54
  args << "~" if approximate
@@ -63,14 +65,30 @@ class Redis
63
65
  # redis.xtrim('mystream', 1000)
64
66
  # @example With options
65
67
  # redis.xtrim('mystream', 1000, approximate: true)
66
- #
67
- # @param key [String] the stream key
68
- # @param mexlen [Integer] max length of entries
69
- # @param approximate [Boolean] whether to add `~` modifier of maxlen or not
68
+ # @example With strategy
69
+ # redis.xtrim('mystream', '1-0', strategy: 'MINID')
70
+ #
71
+ # @overload xtrim(key, maxlen, strategy: 'MAXLEN', approximate: true)
72
+ # @param key [String] the stream key
73
+ # @param maxlen [Integer] max length of entries
74
+ # @param strategy [String] the limit strategy, must be MAXLEN
75
+ # @param approximate [Boolean] whether to add `~` modifier of maxlen or not
76
+ # @param limit [Integer] maximum count of entries to be evicted
77
+ # @overload xtrim(key, minid, strategy: 'MINID', approximate: true)
78
+ # @param key [String] the stream key
79
+ # @param minid [String] minimum id of entries
80
+ # @param strategy [String] the limit strategy, must be MINID
81
+ # @param approximate [Boolean] whether to add `~` modifier of minid or not
82
+ # @param limit [Integer] maximum count of entries to be evicted
70
83
  #
71
84
  # @return [Integer] the number of entries actually deleted
72
- def xtrim(key, maxlen, approximate: false)
73
- args = [:xtrim, key, 'MAXLEN', (approximate ? '~' : nil), maxlen].compact
85
+ def xtrim(key, len_or_id, strategy: 'MAXLEN', approximate: false, limit: nil)
86
+ strategy = strategy.to_s.upcase
87
+
88
+ args = [:xtrim, key, strategy]
89
+ args << '~' if approximate
90
+ args << len_or_id
91
+ args.concat(['LIMIT', limit]) if limit
74
92
  send_command(args)
75
93
  end
76
94
 
@@ -119,7 +119,9 @@ class Redis
119
119
  HashifyStreamAutoclaim = lambda { |reply|
120
120
  {
121
121
  'next' => reply[0],
122
- 'entries' => reply[1].map { |entry| [entry[0], entry[1].each_slice(2).to_h] }
122
+ 'entries' => reply[1].compact.map do |entry, values|
123
+ [entry, values.each_slice(2)&.to_h]
124
+ end
123
125
  }
124
126
  }
125
127
 
data/lib/redis/errors.rb CHANGED
@@ -26,9 +26,6 @@ class Redis
26
26
  class WrongTypeError < CommandError
27
27
  end
28
28
 
29
- class ReadOnlyError < CommandError
30
- end
31
-
32
29
  class OutOfMemoryError < CommandError
33
30
  end
34
31
 
@@ -52,6 +49,10 @@ class Redis
52
49
  class InheritedError < BaseConnectionError
53
50
  end
54
51
 
52
+ # Generally raised during Redis failover scenarios
53
+ class ReadOnlyError < BaseConnectionError
54
+ end
55
+
55
56
  # Raised when client options are invalid.
56
57
  class InvalidClientOptionError < BaseError
57
58
  end
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.5'
4
+ VERSION = '5.0.6'
5
5
  end
data/lib/redis.rb CHANGED
@@ -133,7 +133,7 @@ class Redis
133
133
 
134
134
  def initialize_client(options)
135
135
  if options.key?(:cluster)
136
- raise "Redis Cluster support was moved to the `redis_cluster` gem."
136
+ raise "Redis Cluster support was moved to the `redis-clustering` gem."
137
137
  end
138
138
 
139
139
  if options.key?(:sentinels)
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.5
4
+ version: 5.0.6
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-09-22 00:00:00.000000000 Z
19
+ date: 2023-01-16 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.5
78
+ documentation_uri: https://www.rubydoc.info/gems/redis/5.0.6
79
79
  homepage_uri: https://github.com/redis/redis-rb
80
- source_code_uri: https://github.com/redis/redis-rb/tree/v5.0.5
80
+ source_code_uri: https://github.com/redis/redis-rb/tree/v5.0.6
81
81
  post_install_message:
82
82
  rdoc_options: []
83
83
  require_paths: