redis-client 0.19.0 → 0.20.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 +10 -0
- data/Gemfile.lock +26 -20
- data/README.md +3 -1
- data/lib/redis_client/config.rb +14 -3
- data/lib/redis_client/ruby_connection/resp3.rb +3 -3
- data/lib/redis_client/url_config.rb +29 -8
- data/lib/redis_client/version.rb +1 -1
- data/redis-client.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154db13231ff43137f013f9ef224846201eabf5fef93059a5ed48206e558f238
|
4
|
+
data.tar.gz: 882208c7ad423619cc19cdc3c0b9ae02bd75e425bd702e29b1f2104896a4e0cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e3d3fa8d9684387519cdcc90a7c43319678defa957087902fdb2297ada820cbe746c7821126bcfbdc1f35877bb642382c7b5abebd4a227b2b60a24b8944b4f8
|
7
|
+
data.tar.gz: 40ceb06e68a8fabd9dd067ab177f5e6ca83b9af04e04b8f166bdc36e33ddd642190c400446e029c91b8416eb44f17aeb5cea950b06b7afc2daf6fa5514bef3f3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# 0.20.0
|
4
|
+
|
5
|
+
- Accept `unix://` schemes as well as simple paths in the `url:` config parameter. #170.
|
6
|
+
- Make basic usage Ractor compatible.
|
7
|
+
|
8
|
+
# 0.19.1
|
9
|
+
|
10
|
+
- Fixed a bug in `hiredis-client` that could cause a crash if interrupted by `Timeout.timeout` or other `Thread#raise` based mecanism.
|
11
|
+
- Fixed a GC bug that could cause crashes in `hiredis-client`.
|
12
|
+
|
3
13
|
# 0.19.0
|
4
14
|
|
5
15
|
- Revalidate connection in `RedisClient#connected?`
|
data/Gemfile.lock
CHANGED
@@ -1,46 +1,52 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
redis-client (0.
|
4
|
+
redis-client (0.20.0)
|
5
5
|
connection_pool
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
ast (2.4.2)
|
11
|
-
benchmark-ips (2.
|
11
|
+
benchmark-ips (2.13.0)
|
12
12
|
byebug (11.1.3)
|
13
13
|
connection_pool (2.4.1)
|
14
14
|
hiredis (0.6.3)
|
15
15
|
hiredis (0.6.3-java)
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
json (2.7.1)
|
17
|
+
json (2.7.1-java)
|
18
|
+
minitest (5.22.0)
|
19
|
+
parallel (1.24.0)
|
20
|
+
parser (3.3.0.5)
|
19
21
|
ast (~> 2.4.1)
|
22
|
+
racc
|
23
|
+
racc (1.7.3)
|
24
|
+
racc (1.7.3-java)
|
20
25
|
rainbow (3.1.1)
|
21
26
|
rake (13.1.0)
|
22
|
-
rake-compiler (1.2.
|
27
|
+
rake-compiler (1.2.7)
|
23
28
|
rake
|
24
29
|
redis (4.6.0)
|
25
|
-
regexp_parser (2.
|
26
|
-
rexml (3.2.
|
27
|
-
rubocop (1.
|
30
|
+
regexp_parser (2.9.0)
|
31
|
+
rexml (3.2.6)
|
32
|
+
rubocop (1.50.2)
|
33
|
+
json (~> 2.3)
|
28
34
|
parallel (~> 1.10)
|
29
|
-
parser (>= 3.
|
35
|
+
parser (>= 3.2.0.0)
|
30
36
|
rainbow (>= 2.2.2, < 4.0)
|
31
37
|
regexp_parser (>= 1.8, < 3.0)
|
32
|
-
rexml
|
33
|
-
rubocop-ast (>= 1.
|
38
|
+
rexml (>= 3.2.5, < 4.0)
|
39
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
34
40
|
ruby-progressbar (~> 1.7)
|
35
|
-
unicode-display_width (>=
|
36
|
-
rubocop-ast (1.
|
37
|
-
parser (>= 3.
|
38
|
-
rubocop-minitest (0.
|
39
|
-
rubocop (>=
|
40
|
-
ruby-progressbar (1.
|
41
|
-
stackprof (0.2.
|
41
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
42
|
+
rubocop-ast (1.30.0)
|
43
|
+
parser (>= 3.2.1.0)
|
44
|
+
rubocop-minitest (0.30.0)
|
45
|
+
rubocop (>= 1.39, < 2.0)
|
46
|
+
ruby-progressbar (1.13.0)
|
47
|
+
stackprof (0.2.26)
|
42
48
|
toxiproxy (2.0.2)
|
43
|
-
unicode-display_width (2.
|
49
|
+
unicode-display_width (2.5.0)
|
44
50
|
|
45
51
|
PLATFORMS
|
46
52
|
ruby
|
data/README.md
CHANGED
@@ -62,7 +62,9 @@ redis.call("GET", "mykey")
|
|
62
62
|
|
63
63
|
### Configuration
|
64
64
|
|
65
|
-
- `url`: A Redis connection URL, e.g. `redis://example.com:6379/5
|
65
|
+
- `url`: A Redis connection URL, e.g. `redis://example.com:6379/5` - a `rediss://` scheme enables SSL, and the path is interpreted as a database number.
|
66
|
+
To connect to UNIX domain sockets, the `url` can also just be a path, and the database specified as query parameter: `/run/redis/foo.sock?db=5`, or optionally
|
67
|
+
have a `unix://` scheme: `unix:///run/redis/foo.sock?db=5`
|
66
68
|
Note that all other configurations take precedence, e.g. `RedisClient.config(url: "redis://localhost:3000", port: 6380)` will connect on port `6380`.
|
67
69
|
- `host`: The server hostname or IP address. Defaults to `"localhost"`.
|
68
70
|
- `port`: The server port. Defaults to `6379`.
|
data/lib/redis_client/config.rb
CHANGED
@@ -151,6 +151,12 @@ class RedisClient
|
|
151
151
|
if @db && @db != 0
|
152
152
|
prelude << ["SELECT", @db.to_s]
|
153
153
|
end
|
154
|
+
|
155
|
+
# Deep freeze all the strings and commands
|
156
|
+
prelude.map! do |commands|
|
157
|
+
commands = commands.map { |str| str.frozen? ? str : str.dup.freeze }
|
158
|
+
commands.freeze
|
159
|
+
end
|
154
160
|
prelude.freeze
|
155
161
|
end
|
156
162
|
end
|
@@ -176,15 +182,20 @@ class RedisClient
|
|
176
182
|
}.compact.merge(kwargs)
|
177
183
|
host ||= url_config.host
|
178
184
|
port ||= url_config.port
|
185
|
+
path ||= url_config.path
|
179
186
|
username ||= url_config.username
|
180
187
|
password ||= url_config.password
|
181
188
|
end
|
182
189
|
|
183
190
|
super(username: username, password: password, **kwargs)
|
184
191
|
|
185
|
-
@
|
186
|
-
|
187
|
-
|
192
|
+
if @path = path
|
193
|
+
@host = nil
|
194
|
+
@port = nil
|
195
|
+
else
|
196
|
+
@host = host || DEFAULT_HOST
|
197
|
+
@port = Integer(port || DEFAULT_PORT)
|
198
|
+
end
|
188
199
|
end
|
189
200
|
end
|
190
201
|
end
|
@@ -10,12 +10,12 @@ class RedisClient
|
|
10
10
|
|
11
11
|
EOL = "\r\n".b.freeze
|
12
12
|
EOL_SIZE = EOL.bytesize
|
13
|
-
DUMP_TYPES = {
|
13
|
+
DUMP_TYPES = {
|
14
14
|
String => :dump_string,
|
15
15
|
Symbol => :dump_symbol,
|
16
16
|
Integer => :dump_numeric,
|
17
17
|
Float => :dump_numeric,
|
18
|
-
}
|
18
|
+
}.freeze
|
19
19
|
PARSER_TYPES = {
|
20
20
|
'#' => :parse_boolean,
|
21
21
|
'$' => :parse_blob,
|
@@ -57,7 +57,7 @@ class RedisClient
|
|
57
57
|
def dump_any(object, buffer)
|
58
58
|
method = DUMP_TYPES.fetch(object.class) do |unexpected_class|
|
59
59
|
if superclass = DUMP_TYPES.keys.find { |t| t > unexpected_class }
|
60
|
-
DUMP_TYPES[
|
60
|
+
DUMP_TYPES[superclass]
|
61
61
|
else
|
62
62
|
raise TypeError, "Unsupported command argument type: #{unexpected_class}"
|
63
63
|
end
|
@@ -4,26 +4,41 @@ require "uri"
|
|
4
4
|
|
5
5
|
class RedisClient
|
6
6
|
class URLConfig
|
7
|
-
DEFAULT_SCHEMA = "redis"
|
8
|
-
SSL_SCHEMA = "rediss"
|
9
|
-
|
10
7
|
attr_reader :url, :uri
|
11
8
|
|
12
9
|
def initialize(url)
|
13
10
|
@url = url
|
14
11
|
@uri = URI(url)
|
15
|
-
|
16
|
-
|
12
|
+
@unix = false
|
13
|
+
@ssl = false
|
14
|
+
case uri.scheme
|
15
|
+
when "redis"
|
16
|
+
# expected
|
17
|
+
when "rediss"
|
18
|
+
@ssl = true
|
19
|
+
when "unix", nil
|
20
|
+
@unix = true
|
21
|
+
else
|
22
|
+
raise ArgumentError, "Unknown URL scheme: #{url.inspect}"
|
17
23
|
end
|
18
24
|
end
|
19
25
|
|
20
26
|
def ssl?
|
21
|
-
@
|
27
|
+
@ssl
|
22
28
|
end
|
23
29
|
|
24
30
|
def db
|
25
|
-
|
26
|
-
|
31
|
+
unless @unix
|
32
|
+
db_path = uri.path&.delete_prefix("/")
|
33
|
+
return Integer(db_path) if db_path && !db_path.empty?
|
34
|
+
end
|
35
|
+
|
36
|
+
unless uri.query.nil? || uri.query.empty?
|
37
|
+
_, db_query = URI.decode_www_form(uri.query).find do |key, _|
|
38
|
+
key == "db"
|
39
|
+
end
|
40
|
+
return Integer(db_query) if db_query && !db_query.empty?
|
41
|
+
end
|
27
42
|
end
|
28
43
|
|
29
44
|
def username
|
@@ -44,6 +59,12 @@ class RedisClient
|
|
44
59
|
uri.host.sub(/\A\[(.*)\]\z/, '\1')
|
45
60
|
end
|
46
61
|
|
62
|
+
def path
|
63
|
+
if @unix
|
64
|
+
File.join(*[uri.host, uri.path].compact)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
47
68
|
def port
|
48
69
|
return unless uri.port
|
49
70
|
|
data/lib/redis_client/version.rb
CHANGED
data/redis-client.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.summary = "Simple low-level client for Redis 6+"
|
12
12
|
spec.homepage = "https://github.com/redis-rb/redis-client"
|
13
13
|
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = ">= 2.
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
15
|
|
16
16
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
17
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|
@@ -70,14 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 2.
|
73
|
+
version: 2.6.0
|
74
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
80
|
+
rubygems_version: 3.5.5
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Simple low-level client for Redis 6+
|