redis 5.0.7 → 5.0.8
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 +5 -0
- data/README.md +26 -6
- data/lib/redis/client.rb +0 -4
- data/lib/redis/commands/pubsub.rb +21 -0
- data/lib/redis/subscribe.rb +29 -1
- data/lib/redis/version.rb +1 -1
- data/lib/redis.rb +1 -16
- 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: 68e827844bdac2fa5954e99fd259060a232719927db426788368408b02011eff
|
4
|
+
data.tar.gz: 46f7f0f74538f29ac4b8f72bc0e2cecaeeea44568174c25d61cf3532869c9f3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 996e87442dda9f5750a529b9a14627c371b8e042bc6a7c0a5a32d0c36effa24728d10404a983cea0ef07f19c6e6f1571ac75af1d14a5480021445e23a7eb24e5
|
7
|
+
data.tar.gz: d36cc39b9d847badfe8d63a94ac74ee588a4fa856581e93f113261156be4b6d6e802b207af6fbe526ff7fb3a00b00f27e4f935a2164da18eb329b6eb007dfb4d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# 5.0.8
|
4
|
+
|
5
|
+
- Fix `Redis#without_reconnect` for sentinel clients. Fix #1212.
|
6
|
+
- Add `sentinel_username`, `sentinel_password` for sentinel clients. Bump `redis-client` to `>=0.17.0`. See #1213
|
7
|
+
|
3
8
|
# 5.0.7
|
4
9
|
|
5
10
|
- Fix compatibility with `redis-client 0.15.0` when using Redis Sentinel. Fix #1209.
|
data/README.md
CHANGED
@@ -120,19 +120,39 @@ but a few so that if one is down the client will try the next one. The client
|
|
120
120
|
is able to remember the last Sentinel that was able to reply correctly and will
|
121
121
|
use it for the next requests.
|
122
122
|
|
123
|
-
|
123
|
+
To [authenticate](https://redis.io/docs/management/sentinel/#configuring-sentinel-instances-with-authentication) Sentinel itself, you can specify the `sentinel_username` and `sentinel_password`. Exclude the `sentinel_username` option if you're using password-only authentication.
|
124
124
|
|
125
125
|
```ruby
|
126
|
-
SENTINELS = [{ host: '127.0.0.1', port: 26380
|
127
|
-
{ host: '127.0.0.1', port: 26381
|
126
|
+
SENTINELS = [{ host: '127.0.0.1', port: 26380},
|
127
|
+
{ host: '127.0.0.1', port: 26381}]
|
128
128
|
|
129
|
-
redis = Redis.new(name: 'mymaster', sentinels: SENTINELS, role: :master)
|
129
|
+
redis = Redis.new(name: 'mymaster', sentinels: SENTINELS, sentinel_username: 'appuser', sentinel_password: 'mysecret', role: :master)
|
130
130
|
```
|
131
131
|
|
132
|
-
|
132
|
+
If you specify a username and/or password at the top level for your main Redis instance, Sentinel *will not* using thouse credentials
|
133
133
|
|
134
134
|
```ruby
|
135
|
-
|
135
|
+
# Use 'mysecret' to authenticate against the mymaster instance, but skip authentication for the sentinels:
|
136
|
+
SENTINELS = [{ host: '127.0.0.1', port: 26380 },
|
137
|
+
{ host: '127.0.0.1', port: 26381 }]
|
138
|
+
|
139
|
+
redis = Redis.new(name: 'mymaster', sentinels: SENTINELS, role: :master, password: 'mysecret')
|
140
|
+
```
|
141
|
+
|
142
|
+
So you have to provide Sentinel credential and Redis explictly even they are the same
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
# Use 'mysecret' to authenticate against the mymaster instance and sentinel
|
146
|
+
SENTINELS = [{ host: '127.0.0.1', port: 26380 },
|
147
|
+
{ host: '127.0.0.1', port: 26381 }]
|
148
|
+
|
149
|
+
redis = Redis.new(name: 'mymaster', sentinels: SENTINELS, role: :master, password: 'mysecret', sentinel_password: 'mysecret')
|
150
|
+
```
|
151
|
+
|
152
|
+
Also the `name`, `password`, `username` and `db` for Redis instance can be passed as an url:
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
redis = Redis.new(url: "redis://appuser:mysecret@mymaster/10", sentinels: SENTINELS, role: :master)
|
136
156
|
```
|
137
157
|
|
138
158
|
## Cluster support
|
data/lib/redis/client.rb
CHANGED
@@ -49,6 +49,27 @@ class Redis
|
|
49
49
|
def pubsub(subcommand, *args)
|
50
50
|
send_command([:pubsub, subcommand] + args)
|
51
51
|
end
|
52
|
+
|
53
|
+
# Post a message to a channel in a shard.
|
54
|
+
def spublish(channel, message)
|
55
|
+
send_command([:spublish, channel, message])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Listen for messages published to the given channels in a shard.
|
59
|
+
def ssubscribe(*channels, &block)
|
60
|
+
_subscription(:ssubscribe, 0, channels, block)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Listen for messages published to the given channels in a shard.
|
64
|
+
# Throw a timeout error if there is no messages for a timeout period.
|
65
|
+
def ssubscribe_with_timeout(timeout, *channels, &block)
|
66
|
+
_subscription(:ssubscribe_with_timeout, timeout, channels, block)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Stop listening for messages posted to the given channels in a shard.
|
70
|
+
def sunsubscribe(*channels)
|
71
|
+
_subscription(:sunsubscribe, 0, channels, nil)
|
72
|
+
end
|
52
73
|
end
|
53
74
|
end
|
54
75
|
end
|
data/lib/redis/subscribe.rb
CHANGED
@@ -29,6 +29,14 @@ class Redis
|
|
29
29
|
subscription("psubscribe", "punsubscribe", channels, block, timeout)
|
30
30
|
end
|
31
31
|
|
32
|
+
def ssubscribe(*channels, &block)
|
33
|
+
subscription("ssubscribe", "sunsubscribe", channels, block)
|
34
|
+
end
|
35
|
+
|
36
|
+
def ssubscribe_with_timeout(timeout, *channels, &block)
|
37
|
+
subscription("ssubscribe", "sunsubscribe", channels, block, timeout)
|
38
|
+
end
|
39
|
+
|
32
40
|
def unsubscribe(*channels)
|
33
41
|
call_v([:unsubscribe, *channels])
|
34
42
|
end
|
@@ -37,6 +45,10 @@ class Redis
|
|
37
45
|
call_v([:punsubscribe, *channels])
|
38
46
|
end
|
39
47
|
|
48
|
+
def sunsubscribe(*channels)
|
49
|
+
call_v([:sunsubscribe, *channels])
|
50
|
+
end
|
51
|
+
|
40
52
|
def close
|
41
53
|
@client.close
|
42
54
|
end
|
@@ -46,7 +58,11 @@ class Redis
|
|
46
58
|
def subscription(start, stop, channels, block, timeout = 0)
|
47
59
|
sub = Subscription.new(&block)
|
48
60
|
|
49
|
-
|
61
|
+
case start
|
62
|
+
when "ssubscribe" then channels.each { |c| call_v([start, c]) } # avoid cross-slot keys
|
63
|
+
else call_v([start, *channels])
|
64
|
+
end
|
65
|
+
|
50
66
|
while event = @client.next_event(timeout)
|
51
67
|
if event.is_a?(::RedisClient::CommandError)
|
52
68
|
raise Client::ERROR_MAPPING.fetch(event.class), event.message
|
@@ -94,5 +110,17 @@ class Redis
|
|
94
110
|
def pmessage(&block)
|
95
111
|
@callbacks["pmessage"] = block
|
96
112
|
end
|
113
|
+
|
114
|
+
def ssubscribe(&block)
|
115
|
+
@callbacks["ssubscribe"] = block
|
116
|
+
end
|
117
|
+
|
118
|
+
def sunsubscribe(&block)
|
119
|
+
@callbacks["sunsubscribe"] = block
|
120
|
+
end
|
121
|
+
|
122
|
+
def smessage(&block)
|
123
|
+
@callbacks["smessage"] = block
|
124
|
+
end
|
97
125
|
end
|
98
126
|
end
|
data/lib/redis/version.rb
CHANGED
data/lib/redis.rb
CHANGED
@@ -45,7 +45,7 @@ class Redis
|
|
45
45
|
# @option options [String] :host ("127.0.0.1") server hostname
|
46
46
|
# @option options [Integer] :port (6379) server port
|
47
47
|
# @option options [String] :path path to server socket (overrides host and port)
|
48
|
-
# @option options [Float] :timeout (
|
48
|
+
# @option options [Float] :timeout (1.0) timeout in seconds
|
49
49
|
# @option options [Float] :connect_timeout (same as timeout) timeout for initial connect in seconds
|
50
50
|
# @option options [String] :username Username to authenticate against server
|
51
51
|
# @option options [String] :password Password to authenticate against server
|
@@ -137,21 +137,6 @@ class Redis
|
|
137
137
|
end
|
138
138
|
|
139
139
|
if options.key?(:sentinels)
|
140
|
-
if url = options.delete(:url)
|
141
|
-
uri = URI.parse(url)
|
142
|
-
if !options.key?(:name) && uri.host
|
143
|
-
options[:name] = uri.host
|
144
|
-
end
|
145
|
-
|
146
|
-
if !options.key?(:password) && uri.password && !uri.password.empty?
|
147
|
-
options[:password] = uri.password
|
148
|
-
end
|
149
|
-
|
150
|
-
if !options.key?(:username) && uri.user && !uri.user.empty?
|
151
|
-
options[:username] = uri.user
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
140
|
Client.sentinel(**options).new_client
|
156
141
|
else
|
157
142
|
Client.config(**options).new_client
|
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.8
|
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: 2023-
|
19
|
+
date: 2023-10-23 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.17.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.17.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.8
|
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.8
|
81
81
|
post_install_message:
|
82
82
|
rdoc_options: []
|
83
83
|
require_paths:
|