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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +22 -0
- data/lib/redis/client.rb +1 -1
- data/lib/redis/pipeline.rb +7 -5
- data/lib/redis/version.rb +1 -1
- data/lib/redis.rb +4 -3
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 279ebf60fc356e29bbf9872320212da91f48565192b3c6e0d86113bfda5866d9
|
4
|
+
data.tar.gz: f152547a2623146e621848ec0fffb376c162220595ca2fba4fc7bbd21cfa0f67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/lib/redis/pipeline.rb
CHANGED
@@ -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
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.
|
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-
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|
96
|
+
rubygems_version: 3.5.3
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: A Ruby client library for Redis
|