redis 5.1.0 → 5.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab20cee7f44b7d5f2736e1fbc7073cb950f52ceefc3dc1ff0edf9b4b778c7d8d
4
- data.tar.gz: 76b0b6169311906b2ee634f9314c74052a1612245d7e33220aab5cb2c617af8a
3
+ metadata.gz: 279ebf60fc356e29bbf9872320212da91f48565192b3c6e0d86113bfda5866d9
4
+ data.tar.gz: f152547a2623146e621848ec0fffb376c162220595ca2fba4fc7bbd21cfa0f67
5
5
  SHA512:
6
- metadata.gz: 220927cf03b0ad6ab0c7340d9b32ed073e379974d054eba12cf966ad65837eba00f114d1fdeb166780ead645befcc3ee9fb3a83aab8e8cb0b1661370f401f8cb
7
- data.tar.gz: 8f9476be4c7d4a3dd8dc1f29265b184932f67b49d524a0c79865dc95eee3ba165e9d24cb3f699ce287b886cc4f38b88574a5b33b1bab48f2fe9971597b7d2c5c
6
+ metadata.gz: 48c436c76fedc6951edfee5c5f437bb9ca6aad07fd2eccc8c3c0882bf8c113579df381d947b54e35ce2702254a41494b36f6d8fdae4efa6ba46f8285833b4000
7
+ data.tar.gz: 96a3f2d64afc84175165aa9c1cca3a37c1be04b9f882dba8a30ce350ef0acf52e7d2c4c848ad288257a3ab1e18ca37857307e3b6f9e9e49699498cc00a44fda6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Unreleased
2
2
 
3
+ # 5.2.0
4
+
5
+ - Now require Ruby 2.6 because `redis-client` does.
6
+ - Eagerly close subscribed connection when using `subscribe_with_timeout`. See #1259.
7
+ - Add `exception` flag in `pipelined` allowing failed commands to be returned in the result array when set to `false`.
8
+
3
9
  # 5.1.0
4
10
 
5
11
  - `multi` now accept a `watch` keyword argument like `redis-client`. See #1236.
data/README.md CHANGED
@@ -191,6 +191,28 @@ end
191
191
  # => ["OK"]
192
192
  ```
193
193
 
194
+ ### Exception management
195
+
196
+ The `exception` flag in the `#pipelined` is a feature that modifies the pipeline execution behavior. When set
197
+ to `false`, it doesn't raise an exception when a command error occurs. Instead, it allows the pipeline to execute all
198
+ commands, and any failed command will be available in the returned array. (Defaults to `true`)
199
+
200
+ ```ruby
201
+ results = redis.pipelined(exception: false) do |pipeline|
202
+ pipeline.set('key1', 'value1')
203
+ pipeline.lpush('key1', 'something') # This will fail
204
+ pipeline.set('key2', 'value2')
205
+ end
206
+ # results => ["OK", #<RedisClient::WrongTypeError: WRONGTYPE Operation against a key holding the wrong kind of value>, "OK"]
207
+
208
+ results.each do |result|
209
+ if result.is_a?(Redis::CommandError)
210
+ # Do something with the failed result
211
+ end
212
+ end
213
+ ```
214
+
215
+
194
216
  ### Executing commands atomically
195
217
 
196
218
  You can use `MULTI/EXEC` to run a number of commands in an atomic
data/lib/redis/client.rb CHANGED
@@ -105,7 +105,7 @@ class Redis
105
105
  Client.translate_error!(error)
106
106
  end
107
107
 
108
- def pipelined
108
+ def pipelined(exception: true)
109
109
  super
110
110
  rescue ::RedisClient::Error => error
111
111
  Client.translate_error!(error)
@@ -6,9 +6,10 @@ class Redis
6
6
  class PipelinedConnection
7
7
  attr_accessor :db
8
8
 
9
- def initialize(pipeline, futures = [])
9
+ def initialize(pipeline, futures = [], exception: true)
10
10
  @pipeline = pipeline
11
11
  @futures = futures
12
+ @exception = exception
12
13
  end
13
14
 
14
15
  include Commands
@@ -37,7 +38,7 @@ class Redis
37
38
  end
38
39
 
39
40
  def send_command(command, &block)
40
- future = Future.new(command, block)
41
+ future = Future.new(command, block, @exception)
41
42
  @pipeline.call_v(command) do |result|
42
43
  future._set(result)
43
44
  end
@@ -46,7 +47,7 @@ class Redis
46
47
  end
47
48
 
48
49
  def send_blocking_command(command, timeout, &block)
49
- future = Future.new(command, block)
50
+ future = Future.new(command, block, @exception)
50
51
  @pipeline.blocking_call_v(timeout, command) do |result|
51
52
  future._set(result)
52
53
  end
@@ -79,10 +80,11 @@ class Redis
79
80
  class Future < BasicObject
80
81
  FutureNotReady = ::Redis::FutureNotReady.new
81
82
 
82
- def initialize(command, coerce)
83
+ def initialize(command, coerce, exception)
83
84
  @command = command
84
85
  @object = FutureNotReady
85
86
  @coerce = coerce
87
+ @exception = exception
86
88
  end
87
89
 
88
90
  def inspect
@@ -95,7 +97,7 @@ class Redis
95
97
  end
96
98
 
97
99
  def value
98
- ::Kernel.raise(@object) if @object.is_a?(::StandardError)
100
+ ::Kernel.raise(@object) if @exception && @object.is_a?(::StandardError)
99
101
  @object
100
102
  end
101
103
 
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.1.0'
4
+ VERSION = '5.2.0'
5
5
  end
data/lib/redis.rb CHANGED
@@ -99,10 +99,10 @@ class Redis
99
99
  @client
100
100
  end
101
101
 
102
- def pipelined
102
+ def pipelined(exception: true)
103
103
  synchronize do |client|
104
- client.pipelined do |raw_pipeline|
105
- yield PipelinedConnection.new(raw_pipeline)
104
+ client.pipelined(exception: exception) do |raw_pipeline|
105
+ yield PipelinedConnection.new(raw_pipeline, exception: exception)
106
106
  end
107
107
  end
108
108
  end
@@ -175,6 +175,7 @@ class Redis
175
175
  @subscription_client.send(method, *channels, &block)
176
176
  end
177
177
  ensure
178
+ @subscription_client&.close
178
179
  @subscription_client = nil
179
180
  end
180
181
  else
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.1.0
4
+ version: 5.2.0
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: 2024-02-09 00:00:00.000000000 Z
19
+ date: 2024-04-15 00:00:00.000000000 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: redis-client
@@ -24,14 +24,14 @@ dependencies:
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.17.0
27
+ version: 0.22.0
28
28
  type: :runtime
29
29
  prerelease: false
30
30
  version_requirements: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 0.17.0
34
+ version: 0.22.0
35
35
  description: |2
36
36
  A Ruby client that tries to match Redis' API one-to-one, while still
37
37
  providing an idiomatic interface.
@@ -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.1.0
78
+ documentation_uri: https://www.rubydoc.info/gems/redis/5.2.0
79
79
  homepage_uri: https://github.com/redis/redis-rb
80
- source_code_uri: https://github.com/redis/redis-rb/tree/v5.1.0
80
+ source_code_uri: https://github.com/redis/redis-rb/tree/v5.2.0
81
81
  post_install_message:
82
82
  rdoc_options: []
83
83
  require_paths:
@@ -86,14 +86,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 2.5.0
89
+ version: 2.6.0
90
90
  required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  requirements: []
96
- rubygems_version: 3.3.7
96
+ rubygems_version: 3.5.3
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: A Ruby client library for Redis