redis 5.0.4 → 5.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +2 -2
- data/lib/redis/client.rb +3 -26
- data/lib/redis/commands/hashes.rb +1 -1
- data/lib/redis/commands/streams.rb +27 -9
- data/lib/redis/commands/strings.rb +2 -2
- data/lib/redis/commands.rb +3 -1
- data/lib/redis/errors.rb +4 -3
- data/lib/redis/version.rb +1 -1
- data/lib/redis.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b000349da8b2f7ae8ed14909175306d2c719a9873bf1dabe05c4719ae96d0da
|
4
|
+
data.tar.gz: fdcda2f50f9d33265f7ba24d3f29a2e078fabe5240e1eaf01efae51e0b83eb0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 990972ebefe548f952cbf630708298f52c1856fa5a142a341f2548bd9173f03f0106d6b745c7e39cc5baa9f084d5fea5e4c0bf42cf1d42df94e404f3558d7816
|
7
|
+
data.tar.gz: e52615e0d5b7ca9d554ffc540fdfec524d2aed74ac1c7fc3c727d3096504aa81ff43a85b9e2ce7b21da87edf21ca5f92197171ff1b1c62fa85c7551839e9df83
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
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
|
+
|
8
|
+
# 5.0.5
|
9
|
+
|
10
|
+
- Fix automatic disconnection when the process was forked. See #1157.
|
11
|
+
|
3
12
|
# 5.0.4
|
4
13
|
|
5
14
|
- Cast `ttl` argument to integer in `expire`, `setex` and a few others.
|
@@ -27,6 +36,7 @@
|
|
27
36
|
- Cluster support has been moved to a `redis-clustering` companion gem.
|
28
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.
|
29
38
|
- Better support Float timeout in blocking commands. See #977.
|
39
|
+
- `Redis.new` will now raise an error if provided unknown options.
|
30
40
|
- Removed positional timeout in blocking commands (`BLPOP`, etc). Timeout now must be passed as an option: `r.blpop("key", timeout: 2.5)`
|
31
41
|
- Removed `logger` option.
|
32
42
|
- Removed `reconnect_delay_max` and `reconnect_delay`, you can pass precise sleep durations to `reconnect_attempts` instead.
|
data/README.md
CHANGED
@@ -273,8 +273,8 @@ of durations:
|
|
273
273
|
```ruby
|
274
274
|
Redis.new(reconnect_attempts: [
|
275
275
|
0, # retry immediately
|
276
|
-
0.25 # retry a second time after 250ms
|
277
|
-
1 # retry a third and final time after another 1s
|
276
|
+
0.25, # retry a second time after 250ms
|
277
|
+
1, # retry a third and final time after another 1s
|
278
278
|
])
|
279
279
|
```
|
280
280
|
|
data/lib/redis/client.rb
CHANGED
@@ -28,13 +28,6 @@ class Redis
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def initialize(*)
|
32
|
-
super
|
33
|
-
@inherit_socket = false
|
34
|
-
@pid = nil
|
35
|
-
end
|
36
|
-
ruby2_keywords :initialize if respond_to?(:ruby2_keywords, true)
|
37
|
-
|
38
31
|
def id
|
39
32
|
config.id
|
40
33
|
end
|
@@ -85,9 +78,9 @@ class Redis
|
|
85
78
|
def blocking_call_v(timeout, command, &block)
|
86
79
|
if timeout && timeout > 0
|
87
80
|
# Can't use the command timeout argument as the connection timeout
|
88
|
-
# otherwise it would be very racy. So we add
|
89
|
-
# the network delay.
|
90
|
-
timeout +=
|
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
|
91
84
|
end
|
92
85
|
|
93
86
|
super(timeout, command, &block)
|
@@ -115,11 +108,6 @@ class Redis
|
|
115
108
|
@inherit_socket = true
|
116
109
|
end
|
117
110
|
|
118
|
-
def close
|
119
|
-
super
|
120
|
-
@pid = nil
|
121
|
-
end
|
122
|
-
|
123
111
|
private
|
124
112
|
|
125
113
|
def translate_error!(error)
|
@@ -136,16 +124,5 @@ class Redis
|
|
136
124
|
raise
|
137
125
|
end
|
138
126
|
end
|
139
|
-
|
140
|
-
def ensure_connected(retryable: true)
|
141
|
-
unless @inherit_socket || (@pid ||= Process.pid) == Process.pid
|
142
|
-
raise InheritedError,
|
143
|
-
"Tried to use a connection from a child process without reconnecting. " \
|
144
|
-
"You need to reconnect to Redis after forking " \
|
145
|
-
"or set :inherit_socket to true."
|
146
|
-
end
|
147
|
-
|
148
|
-
super
|
149
|
-
end
|
150
127
|
end
|
151
128
|
end
|
@@ -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,17 +43,19 @@ 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
|
53
55
|
args << maxlen
|
54
56
|
end
|
55
57
|
args << id
|
56
|
-
args.concat(entry.
|
58
|
+
args.concat(entry.flatten)
|
57
59
|
send_command(args)
|
58
60
|
end
|
59
61
|
|
@@ -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
|
-
#
|
68
|
-
#
|
69
|
-
# @
|
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,
|
73
|
-
|
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
|
|
@@ -152,7 +152,7 @@ class Redis
|
|
152
152
|
#
|
153
153
|
# @see #mset
|
154
154
|
def mapped_mset(hash)
|
155
|
-
mset(hash.
|
155
|
+
mset(hash.flatten)
|
156
156
|
end
|
157
157
|
|
158
158
|
# Set one or more values, only if none of the keys exist.
|
@@ -180,7 +180,7 @@ class Redis
|
|
180
180
|
#
|
181
181
|
# @see #msetnx
|
182
182
|
def mapped_msetnx(hash)
|
183
|
-
msetnx(hash.
|
183
|
+
msetnx(hash.flatten)
|
184
184
|
end
|
185
185
|
|
186
186
|
# Get the value of a key.
|
data/lib/redis/commands.rb
CHANGED
@@ -119,7 +119,9 @@ class Redis
|
|
119
119
|
HashifyStreamAutoclaim = lambda { |reply|
|
120
120
|
{
|
121
121
|
'next' => reply[0],
|
122
|
-
'entries' => reply[1].map
|
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
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 `
|
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.
|
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:
|
19
|
+
date: 2023-01-16 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.9.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.9.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.0.
|
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.
|
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:
|