redis-client 0.3.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +1 -2
- data/README.md +13 -17
- data/Rakefile +41 -22
- data/lib/redis_client/command_builder.rb +8 -0
- data/lib/redis_client/config.rb +13 -5
- data/lib/redis_client/connection_mixin.rb +2 -0
- data/lib/redis_client/version.rb +1 -1
- data/lib/redis_client.rb +31 -15
- data/redis-client.gemspec +2 -4
- metadata +6 -56
- data/.rubocop.yml +0 -191
- data/ext/redis_client/hiredis/export.clang +0 -2
- data/ext/redis_client/hiredis/export.gcc +0 -7
- data/ext/redis_client/hiredis/extconf.rb +0 -69
- data/ext/redis_client/hiredis/hiredis_connection.c +0 -708
- data/ext/redis_client/hiredis/vendor/.gitignore +0 -9
- data/ext/redis_client/hiredis/vendor/.travis.yml +0 -131
- data/ext/redis_client/hiredis/vendor/CHANGELOG.md +0 -364
- data/ext/redis_client/hiredis/vendor/CMakeLists.txt +0 -165
- data/ext/redis_client/hiredis/vendor/COPYING +0 -29
- data/ext/redis_client/hiredis/vendor/Makefile +0 -308
- data/ext/redis_client/hiredis/vendor/README.md +0 -664
- data/ext/redis_client/hiredis/vendor/adapters/ae.h +0 -130
- data/ext/redis_client/hiredis/vendor/adapters/glib.h +0 -156
- data/ext/redis_client/hiredis/vendor/adapters/ivykis.h +0 -84
- data/ext/redis_client/hiredis/vendor/adapters/libev.h +0 -179
- data/ext/redis_client/hiredis/vendor/adapters/libevent.h +0 -175
- data/ext/redis_client/hiredis/vendor/adapters/libuv.h +0 -117
- data/ext/redis_client/hiredis/vendor/adapters/macosx.h +0 -115
- data/ext/redis_client/hiredis/vendor/adapters/qt.h +0 -135
- data/ext/redis_client/hiredis/vendor/alloc.c +0 -86
- data/ext/redis_client/hiredis/vendor/alloc.h +0 -91
- data/ext/redis_client/hiredis/vendor/appveyor.yml +0 -24
- data/ext/redis_client/hiredis/vendor/async.c +0 -887
- data/ext/redis_client/hiredis/vendor/async.h +0 -147
- data/ext/redis_client/hiredis/vendor/async_private.h +0 -75
- data/ext/redis_client/hiredis/vendor/dict.c +0 -352
- data/ext/redis_client/hiredis/vendor/dict.h +0 -126
- data/ext/redis_client/hiredis/vendor/fmacros.h +0 -12
- data/ext/redis_client/hiredis/vendor/hiredis-config.cmake.in +0 -13
- data/ext/redis_client/hiredis/vendor/hiredis.c +0 -1174
- data/ext/redis_client/hiredis/vendor/hiredis.h +0 -336
- data/ext/redis_client/hiredis/vendor/hiredis.pc.in +0 -12
- data/ext/redis_client/hiredis/vendor/hiredis_ssl-config.cmake.in +0 -13
- data/ext/redis_client/hiredis/vendor/hiredis_ssl.h +0 -157
- data/ext/redis_client/hiredis/vendor/hiredis_ssl.pc.in +0 -12
- data/ext/redis_client/hiredis/vendor/net.c +0 -612
- data/ext/redis_client/hiredis/vendor/net.h +0 -56
- data/ext/redis_client/hiredis/vendor/read.c +0 -739
- data/ext/redis_client/hiredis/vendor/read.h +0 -129
- data/ext/redis_client/hiredis/vendor/sds.c +0 -1289
- data/ext/redis_client/hiredis/vendor/sds.h +0 -278
- data/ext/redis_client/hiredis/vendor/sdsalloc.h +0 -44
- data/ext/redis_client/hiredis/vendor/sockcompat.c +0 -248
- data/ext/redis_client/hiredis/vendor/sockcompat.h +0 -92
- data/ext/redis_client/hiredis/vendor/ssl.c +0 -544
- data/ext/redis_client/hiredis/vendor/test.c +0 -1401
- data/ext/redis_client/hiredis/vendor/test.sh +0 -78
- data/ext/redis_client/hiredis/vendor/win32.h +0 -56
- data/lib/redis_client/hiredis_connection.rb +0 -93
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b23930fc431afe23313aca3ef90ba49f219a6ed1a50f8153075a09b4c43678c0
|
4
|
+
data.tar.gz: 502388c79068a1dfe166543a6eb91cead665f42e404f679a598f5a8e2844ee82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f6d4422b8c3e6608a5a8c53a55335ad0c44c034bc2cf26c7b5aace8dfdbe799409dd9783bd5928da3453d60ed28579594676f95c951a6a4dfff5e04dd09d28d
|
7
|
+
data.tar.gz: 3ee257ab6d509606c959079a16886389d76bfe232876aba9de1ae8922031746ad2576224fc5b0fae44a09ef13ba4d14ea862098860f923f432f63454499c1677
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# Unreleased
|
2
2
|
|
3
|
+
# 0.5.1
|
4
|
+
|
5
|
+
- Fix a regression in the `scan` familly of methods, they would raise with `ArgumentError: can't issue an empty redis command`. Fix: #24
|
6
|
+
|
7
|
+
# 0.5.0
|
8
|
+
|
9
|
+
- Fix handling of connection URLs with empty passwords (`redis://:pass@example.com`).
|
10
|
+
- Handle URLs with IPv6 hosts.
|
11
|
+
- Add `RedisClient::Config#server_url` as a quick way to identify which server the client is pointing to.
|
12
|
+
- Add `CommandError#command` to expose the command that caused the error.
|
13
|
+
- Raise a more explicit error when connecting to older redises without RESP3 support (5.0 and older).
|
14
|
+
- Properly reject empty commands early.
|
15
|
+
|
16
|
+
# 0.4.0
|
17
|
+
|
18
|
+
- The `hiredis` driver have been moved to the `hiredis-client` gem.
|
19
|
+
|
3
20
|
# 0.3.0
|
4
21
|
|
5
22
|
- `hiredis` is now the default driver when available.
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
`redis-client` is a simple, low-level, client for Redis 6+.
|
4
4
|
|
5
|
-
Contrary to the `redis` gem, `redis-client` doesn't try to map all
|
5
|
+
Contrary to the `redis` gem, `redis-client` doesn't try to map all Redis commands to Ruby constructs,
|
6
6
|
it merely is a thin wrapper on top of the RESP3 protocol.
|
7
7
|
|
8
8
|
## Installation
|
@@ -63,7 +63,7 @@ redis.call("GET", "mykey")
|
|
63
63
|
### Configuration
|
64
64
|
|
65
65
|
- `url`: A Redis connection URL, e.g. `redis://example.com:6379/5`, a `rediss://` scheme enable SSL, and the path is interpreted as a database number.
|
66
|
-
Note
|
66
|
+
Note that all other configurations take precedence, e.g. `RedisClient.config(url: "redis://localhost:3000" port: 6380)` will connect on port `6380`.
|
67
67
|
- `host`: The server hostname or IP address. Defaults to `"localhost"`.
|
68
68
|
- `port`: The server port. Defaults to `6379`.
|
69
69
|
- `path`: The path to a UNIX socket, if set `url`, `host` and `port` are ignored.
|
@@ -142,7 +142,7 @@ is equivalent to:
|
|
142
142
|
redis.call("LPUSH", "list", "1", "2", "3", "4")
|
143
143
|
```
|
144
144
|
|
145
|
-
Hashes are
|
145
|
+
Hashes are flattened as well:
|
146
146
|
|
147
147
|
```ruby
|
148
148
|
redis.call("HMSET", "hash", { "foo" => "1", "bar" => "2" })
|
@@ -154,7 +154,7 @@ is equivalent to:
|
|
154
154
|
redis.call("HMSET", "hash", "foo", "1", "bar", "2")
|
155
155
|
```
|
156
156
|
|
157
|
-
Any other type requires the caller to
|
157
|
+
Any other type requires the caller to explicitly cast the argument as a string.
|
158
158
|
|
159
159
|
Keywords arguments are treated as Redis command flags:
|
160
160
|
|
@@ -170,7 +170,7 @@ redis.call("SET", "mykey", "value", "nx", "ex", "60")
|
|
170
170
|
redis.call("SET", "mykey", "value")
|
171
171
|
```
|
172
172
|
|
173
|
-
If flags are built dynamically, you'll have to
|
173
|
+
If flags are built dynamically, you'll have to explicitly pass them as keyword arguments with `**`:
|
174
174
|
|
175
175
|
```ruby
|
176
176
|
flags = {}
|
@@ -185,7 +185,7 @@ unclosed hash literals with string keys may be interpreted differently:
|
|
185
185
|
redis.call("HMSET", "hash", "foo" => "bar")
|
186
186
|
```
|
187
187
|
|
188
|
-
On Ruby 2 `"foo" => "bar"` will be passed as a
|
188
|
+
On Ruby 2 `"foo" => "bar"` will be passed as a positional argument, but on Ruby 3 it will be interpreted as keyword
|
189
189
|
arguments. To avoid such problem, make sure to enclose hash literals:
|
190
190
|
|
191
191
|
```ruby
|
@@ -196,7 +196,7 @@ redis.call("HMSET", "hash", { "foo" => "bar" })
|
|
196
196
|
|
197
197
|
Contrary to the `redis` gem, `redis-client` doesn't do any type casting on the return value of commands.
|
198
198
|
|
199
|
-
If you wish to cast the return value, you can pass a block to the `#call`
|
199
|
+
If you wish to cast the return value, you can pass a block to the `#call` family of methods:
|
200
200
|
|
201
201
|
```ruby
|
202
202
|
redis.call("INCR", "counter") # => 1
|
@@ -297,7 +297,7 @@ end
|
|
297
297
|
|
298
298
|
If the transaction wasn't successful, `#multi` will return `nil`.
|
299
299
|
|
300
|
-
Note that transactions using optimistic locking aren't automatically retried
|
300
|
+
Note that transactions using optimistic locking aren't automatically retried upon connection errors.
|
301
301
|
|
302
302
|
### Publish / Subscribe
|
303
303
|
|
@@ -389,21 +389,17 @@ redis.call_once("INCR", "counter") # Won't be retried.
|
|
389
389
|
|
390
390
|
### Drivers
|
391
391
|
|
392
|
-
`redis-client` ships with
|
392
|
+
`redis-client` ships with a pure Ruby socket implementation.
|
393
393
|
|
394
|
-
|
395
|
-
|
396
|
-
The default driver can be set through `RedisClient.default_driver=`:
|
394
|
+
For increased performance, you can enable the `hiredis` binding by adding `hiredis-client` to your Gemfile:
|
397
395
|
|
398
396
|
```ruby
|
399
|
-
|
397
|
+
gem "hiredis-client"
|
400
398
|
```
|
401
399
|
|
402
|
-
You can
|
400
|
+
The hiredis binding is only available on Linux, macOS and other POSIX platforms. You can install the gem on other platforms, but it won't have any effect.
|
403
401
|
|
404
|
-
|
405
|
-
redis_config = RedisClient.config(driver: :ruby, ...)
|
406
|
-
```
|
402
|
+
The default driver can be set through `RedisClient.default_driver=`:
|
407
403
|
|
408
404
|
## Notable differences with the `redis` gem
|
409
405
|
|
data/Rakefile
CHANGED
@@ -1,34 +1,53 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "bundler/gem_tasks"
|
4
3
|
require "rake/extensiontask"
|
5
4
|
require "rake/testtask"
|
6
5
|
require 'rubocop/rake_task'
|
7
6
|
|
8
7
|
RuboCop::RakeTask.new
|
9
8
|
|
9
|
+
require "rake/clean"
|
10
|
+
CLOBBER.include "pkg"
|
11
|
+
require "bundler/gem_helper"
|
12
|
+
Bundler::GemHelper.install_tasks(name: "redis-client")
|
13
|
+
Bundler::GemHelper.install_tasks(dir: "hiredis-client", name: "hiredis-client")
|
14
|
+
|
10
15
|
gemspec = Gem::Specification.load("redis-client.gemspec")
|
11
16
|
Rake::ExtensionTask.new do |ext|
|
12
17
|
ext.name = "hiredis_connection"
|
13
|
-
ext.ext_dir = "ext/redis_client/hiredis"
|
14
|
-
ext.lib_dir = "lib/redis_client"
|
18
|
+
ext.ext_dir = "hiredis-client/ext/redis_client/hiredis"
|
19
|
+
ext.lib_dir = "hiredis-client/lib/redis_client"
|
15
20
|
ext.gem_spec = gemspec
|
16
21
|
CLEAN.add("#{ext.ext_dir}/vendor/*.{a,o}")
|
17
22
|
end
|
18
23
|
|
19
|
-
Rake::TestTask.new(:test) do |t|
|
20
|
-
t.libs << "test"
|
21
|
-
t.libs << "lib"
|
22
|
-
t.test_files = FileList["test/**/*_test.rb"].exclude("test/sentinel/*_test.rb")
|
23
|
-
end
|
24
|
-
|
25
24
|
namespace :test do
|
25
|
+
Rake::TestTask.new(:ruby) do |t|
|
26
|
+
t.libs << "test"
|
27
|
+
t.libs << "lib"
|
28
|
+
t.test_files = FileList["test/**/*_test.rb"].exclude("test/sentinel/*_test.rb")
|
29
|
+
end
|
30
|
+
|
26
31
|
Rake::TestTask.new(:sentinel) do |t|
|
27
32
|
t.libs << "test/sentinel"
|
28
33
|
t.libs << "test"
|
29
34
|
t.libs << "lib"
|
30
35
|
t.test_files = FileList["test/sentinel/*_test.rb"]
|
31
36
|
end
|
37
|
+
|
38
|
+
Rake::TestTask.new(:hiredis) do |t|
|
39
|
+
t.libs << "test/hiredis"
|
40
|
+
t.libs << "test"
|
41
|
+
t.libs << "lib"
|
42
|
+
t.test_files = FileList["test/**/*_test.rb"].exclude("test/sentinel/*_test.rb")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
hiredis_supported = RUBY_ENGINE == "ruby" && !RUBY_PLATFORM.match?(/mswin/)
|
47
|
+
if hiredis_supported
|
48
|
+
task test: %i[test:ruby test:hiredis test:sentinel]
|
49
|
+
else
|
50
|
+
task test: %i[test:ruby test:sentinel]
|
32
51
|
end
|
33
52
|
|
34
53
|
namespace :hiredis do
|
@@ -37,10 +56,14 @@ namespace :hiredis do
|
|
37
56
|
archive_path = "tmp/hiredis-#{version}.tar.gz"
|
38
57
|
url = "https://github.com/redis/hiredis/archive/refs/tags/v#{version}.tar.gz"
|
39
58
|
system("curl", "-L", url, out: archive_path) or raise "Downloading of #{url} failed"
|
40
|
-
system("rm", "-rf", "ext/redis_client/hiredis/vendor/")
|
41
|
-
system("mkdir", "-p", "ext/redis_client/hiredis/vendor/")
|
42
|
-
system(
|
43
|
-
|
59
|
+
system("rm", "-rf", "hiredis-client/ext/redis_client/hiredis/vendor/")
|
60
|
+
system("mkdir", "-p", "hiredis-client/ext/redis_client/hiredis/vendor/")
|
61
|
+
system(
|
62
|
+
"tar", "xvzf", archive_path,
|
63
|
+
"-C", "hiredis-client/ext/redis_client/hiredis/vendor",
|
64
|
+
"--strip-components", "1",
|
65
|
+
)
|
66
|
+
system("rm", "-rf", "hiredis-client/ext/redis_client/hiredis/vendor/examples")
|
44
67
|
end
|
45
68
|
end
|
46
69
|
|
@@ -82,14 +105,10 @@ namespace :benchmark do
|
|
82
105
|
end
|
83
106
|
end
|
84
107
|
|
85
|
-
if
|
86
|
-
task default: %i[
|
87
|
-
|
88
|
-
task default: %i[compile test test:sentinel rubocop]
|
89
|
-
end
|
90
|
-
|
91
|
-
if ENV["DRIVER"] == "hiredis"
|
92
|
-
task ci: %i[compile test test:sentinel]
|
108
|
+
if hiredis_supported
|
109
|
+
task default: %i[compile test rubocop]
|
110
|
+
task ci: %i[compile test]
|
93
111
|
else
|
94
|
-
task
|
112
|
+
task default: %i[test rubocop]
|
113
|
+
task ci: %i[test]
|
95
114
|
end
|
@@ -40,6 +40,10 @@ class RedisClient
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
if command.empty?
|
44
|
+
raise ArgumentError, "can't issue an empty redis command"
|
45
|
+
end
|
46
|
+
|
43
47
|
command
|
44
48
|
end
|
45
49
|
else
|
@@ -76,6 +80,10 @@ class RedisClient
|
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
83
|
+
if command.empty?
|
84
|
+
raise ArgumentError, "can't issue an empty redis command"
|
85
|
+
end
|
86
|
+
|
79
87
|
command
|
80
88
|
end
|
81
89
|
end
|
data/lib/redis_client/config.rb
CHANGED
@@ -82,6 +82,14 @@ class RedisClient
|
|
82
82
|
@ssl_context ||= @driver.ssl_context(@ssl_params)
|
83
83
|
end
|
84
84
|
|
85
|
+
def server_url
|
86
|
+
if path
|
87
|
+
"#{path}/#{db}"
|
88
|
+
else
|
89
|
+
"redis#{'s' if ssl?}://#{host}:#{port}/#{db}"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
85
93
|
private
|
86
94
|
|
87
95
|
def build_connection_prelude
|
@@ -110,15 +118,15 @@ class RedisClient
|
|
110
118
|
path: nil,
|
111
119
|
**kwargs
|
112
120
|
)
|
113
|
-
|
114
|
-
|
121
|
+
if url
|
122
|
+
uri = URI.parse(url)
|
115
123
|
kwargs[:ssl] = uri.scheme == "rediss" unless kwargs.key?(:ssl)
|
116
124
|
|
117
|
-
kwargs[:username] ||= uri.user && uri.
|
125
|
+
kwargs[:username] ||= uri.user if uri.password && !uri.user.empty?
|
118
126
|
|
119
127
|
kwargs[:password] ||= if uri.user && !uri.password
|
120
128
|
URI.decode_www_form_component(uri.user)
|
121
|
-
elsif uri
|
129
|
+
elsif uri.user && uri.password
|
122
130
|
URI.decode_www_form_component(uri.password)
|
123
131
|
end
|
124
132
|
|
@@ -127,7 +135,7 @@ class RedisClient
|
|
127
135
|
|
128
136
|
super(**kwargs)
|
129
137
|
|
130
|
-
@host = host || uri&.host || DEFAULT_HOST
|
138
|
+
@host = host || uri&.host&.sub(/\A\[(.*)\]\z/, '\1') || DEFAULT_HOST
|
131
139
|
@port = port || uri&.port || DEFAULT_PORT
|
132
140
|
@path = path
|
133
141
|
end
|
@@ -6,6 +6,7 @@ class RedisClient
|
|
6
6
|
write(command)
|
7
7
|
result = read(timeout)
|
8
8
|
if result.is_a?(CommandError)
|
9
|
+
result._set_command(command)
|
9
10
|
raise result
|
10
11
|
else
|
11
12
|
result
|
@@ -23,6 +24,7 @@ class RedisClient
|
|
23
24
|
timeout = timeouts && timeouts[index]
|
24
25
|
result = read(timeout)
|
25
26
|
if result.is_a?(CommandError)
|
27
|
+
result._set_command(commands[index])
|
26
28
|
exception ||= result
|
27
29
|
end
|
28
30
|
results[index] = result
|
data/lib/redis_client/version.rb
CHANGED
data/lib/redis_client.rb
CHANGED
@@ -24,7 +24,7 @@ class RedisClient
|
|
24
24
|
|
25
25
|
name = name.to_sym
|
26
26
|
unless @driver_definitions.key?(name)
|
27
|
-
raise ArgumentError, "Unknown driver #{name.inspect}, expected one of: `#{
|
27
|
+
raise ArgumentError, "Unknown driver #{name.inspect}, expected one of: `#{@driver_definitions.keys.inspect}`"
|
28
28
|
end
|
29
29
|
|
30
30
|
@drivers[name] ||= @driver_definitions[name]&.call
|
@@ -47,11 +47,6 @@ class RedisClient
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
-
register_driver :hiredis do
|
51
|
-
require "redis_client/hiredis_connection"
|
52
|
-
HiredisConnection
|
53
|
-
end
|
54
|
-
|
55
50
|
register_driver :ruby do
|
56
51
|
require "redis_client/ruby_connection"
|
57
52
|
RubyConnection
|
@@ -83,6 +78,8 @@ class RedisClient
|
|
83
78
|
|
84
79
|
Error = Class.new(StandardError)
|
85
80
|
|
81
|
+
UnsupportedServer = Class.new(Error)
|
82
|
+
|
86
83
|
ConnectionError = Class.new(Error)
|
87
84
|
|
88
85
|
FailoverError = Class.new(ConnectionError)
|
@@ -94,6 +91,8 @@ class RedisClient
|
|
94
91
|
CheckoutTimeoutError = Class.new(ConnectTimeoutError)
|
95
92
|
|
96
93
|
class CommandError < Error
|
94
|
+
attr_reader :command
|
95
|
+
|
97
96
|
class << self
|
98
97
|
def parse(error_message)
|
99
98
|
code = error_message.split(' ', 2).first
|
@@ -101,6 +100,10 @@ class RedisClient
|
|
101
100
|
klass.new(error_message)
|
102
101
|
end
|
103
102
|
end
|
103
|
+
|
104
|
+
def _set_command(command)
|
105
|
+
@command = command
|
106
|
+
end
|
104
107
|
end
|
105
108
|
|
106
109
|
AuthenticationError = Class.new(CommandError)
|
@@ -145,6 +148,11 @@ class RedisClient
|
|
145
148
|
@disable_reconnection = false
|
146
149
|
end
|
147
150
|
|
151
|
+
def inspect
|
152
|
+
id_string = " id=#{id}" if id
|
153
|
+
"#<#{self.class.name} #{config.server_url}#{id_string}>"
|
154
|
+
end
|
155
|
+
|
148
156
|
def size
|
149
157
|
1
|
150
158
|
end
|
@@ -225,8 +233,8 @@ class RedisClient
|
|
225
233
|
return to_enum(__callee__, *args, **kwargs)
|
226
234
|
end
|
227
235
|
|
228
|
-
args = @command_builder.generate!(args, kwargs)
|
229
|
-
scan_list(1,
|
236
|
+
args = @command_builder.generate!(["SCAN", 0] + args, kwargs)
|
237
|
+
scan_list(1, args, &block)
|
230
238
|
end
|
231
239
|
|
232
240
|
def sscan(key, *args, **kwargs, &block)
|
@@ -234,8 +242,8 @@ class RedisClient
|
|
234
242
|
return to_enum(__callee__, key, *args, **kwargs)
|
235
243
|
end
|
236
244
|
|
237
|
-
args = @command_builder.generate!(args, kwargs)
|
238
|
-
scan_list(2,
|
245
|
+
args = @command_builder.generate!(["SSCAN", key, 0] + args, kwargs)
|
246
|
+
scan_list(2, args, &block)
|
239
247
|
end
|
240
248
|
|
241
249
|
def hscan(key, *args, **kwargs, &block)
|
@@ -243,8 +251,8 @@ class RedisClient
|
|
243
251
|
return to_enum(__callee__, key, *args, **kwargs)
|
244
252
|
end
|
245
253
|
|
246
|
-
args = @command_builder.generate!(args, kwargs)
|
247
|
-
scan_pairs(2,
|
254
|
+
args = @command_builder.generate!(["HSCAN", key, 0] + args, kwargs)
|
255
|
+
scan_pairs(2, args, &block)
|
248
256
|
end
|
249
257
|
|
250
258
|
def zscan(key, *args, **kwargs, &block)
|
@@ -252,8 +260,8 @@ class RedisClient
|
|
252
260
|
return to_enum(__callee__, key, *args, **kwargs)
|
253
261
|
end
|
254
262
|
|
255
|
-
args = @command_builder.generate!(args, kwargs)
|
256
|
-
scan_pairs(2,
|
263
|
+
args = @command_builder.generate!(["ZSCAN", key, 0] + args, kwargs)
|
264
|
+
scan_pairs(2, args, &block)
|
257
265
|
end
|
258
266
|
|
259
267
|
def connected?
|
@@ -410,8 +418,9 @@ class RedisClient
|
|
410
418
|
|
411
419
|
def _coerce!(results)
|
412
420
|
if results
|
413
|
-
results.
|
421
|
+
results.each_with_index do |result, index|
|
414
422
|
if result.is_a?(CommandError)
|
423
|
+
result._set_command(@commands[index + 1])
|
415
424
|
raise result
|
416
425
|
end
|
417
426
|
end
|
@@ -563,6 +572,13 @@ class RedisClient
|
|
563
572
|
end
|
564
573
|
|
565
574
|
connection
|
575
|
+
rescue CommandError => error
|
576
|
+
if error.message.include?("ERR unknown command `HELLO`")
|
577
|
+
raise UnsupportedServer,
|
578
|
+
"Your Redis server version is too old. redis-client requires Redis 6+. (#{config.server_url})"
|
579
|
+
else
|
580
|
+
raise
|
581
|
+
end
|
566
582
|
end
|
567
583
|
end
|
568
584
|
|
data/redis-client.gemspec
CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary = "Simple low-level client for Redis 6+"
|
12
12
|
spec.homepage = "https://github.com/redis-rb/redis-client"
|
13
|
+
spec.license = "MIT"
|
13
14
|
spec.required_ruby_version = ">= 2.5.0"
|
14
15
|
|
15
16
|
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
@@ -22,13 +23,10 @@ Gem::Specification.new do |spec|
|
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
25
|
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
-
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features|benchmark)/|\.(?:git|
|
26
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|hiredis-client|test|spec|features|benchmark)/|\.(?:git|rubocop))})
|
26
27
|
end
|
27
28
|
end
|
28
|
-
spec.bindir = "exe"
|
29
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
29
|
spec.require_paths = ["lib"]
|
31
|
-
spec.extensions = ["ext/redis_client/hiredis/extconf.rb"]
|
32
30
|
|
33
31
|
spec.add_runtime_dependency "connection_pool"
|
34
32
|
end
|
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.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|
@@ -28,72 +28,21 @@ description:
|
|
28
28
|
email:
|
29
29
|
- jean.boussier@gmail.com
|
30
30
|
executables: []
|
31
|
-
extensions:
|
32
|
-
- ext/redis_client/hiredis/extconf.rb
|
31
|
+
extensions: []
|
33
32
|
extra_rdoc_files: []
|
34
33
|
files:
|
35
|
-
- ".rubocop.yml"
|
36
34
|
- CHANGELOG.md
|
37
35
|
- Gemfile
|
38
36
|
- Gemfile.lock
|
39
37
|
- LICENSE.md
|
40
38
|
- README.md
|
41
39
|
- Rakefile
|
42
|
-
- ext/redis_client/hiredis/export.clang
|
43
|
-
- ext/redis_client/hiredis/export.gcc
|
44
|
-
- ext/redis_client/hiredis/extconf.rb
|
45
|
-
- ext/redis_client/hiredis/hiredis_connection.c
|
46
|
-
- ext/redis_client/hiredis/vendor/.gitignore
|
47
|
-
- ext/redis_client/hiredis/vendor/.travis.yml
|
48
|
-
- ext/redis_client/hiredis/vendor/CHANGELOG.md
|
49
|
-
- ext/redis_client/hiredis/vendor/CMakeLists.txt
|
50
|
-
- ext/redis_client/hiredis/vendor/COPYING
|
51
|
-
- ext/redis_client/hiredis/vendor/Makefile
|
52
|
-
- ext/redis_client/hiredis/vendor/README.md
|
53
|
-
- ext/redis_client/hiredis/vendor/adapters/ae.h
|
54
|
-
- ext/redis_client/hiredis/vendor/adapters/glib.h
|
55
|
-
- ext/redis_client/hiredis/vendor/adapters/ivykis.h
|
56
|
-
- ext/redis_client/hiredis/vendor/adapters/libev.h
|
57
|
-
- ext/redis_client/hiredis/vendor/adapters/libevent.h
|
58
|
-
- ext/redis_client/hiredis/vendor/adapters/libuv.h
|
59
|
-
- ext/redis_client/hiredis/vendor/adapters/macosx.h
|
60
|
-
- ext/redis_client/hiredis/vendor/adapters/qt.h
|
61
|
-
- ext/redis_client/hiredis/vendor/alloc.c
|
62
|
-
- ext/redis_client/hiredis/vendor/alloc.h
|
63
|
-
- ext/redis_client/hiredis/vendor/appveyor.yml
|
64
|
-
- ext/redis_client/hiredis/vendor/async.c
|
65
|
-
- ext/redis_client/hiredis/vendor/async.h
|
66
|
-
- ext/redis_client/hiredis/vendor/async_private.h
|
67
|
-
- ext/redis_client/hiredis/vendor/dict.c
|
68
|
-
- ext/redis_client/hiredis/vendor/dict.h
|
69
|
-
- ext/redis_client/hiredis/vendor/fmacros.h
|
70
|
-
- ext/redis_client/hiredis/vendor/hiredis-config.cmake.in
|
71
|
-
- ext/redis_client/hiredis/vendor/hiredis.c
|
72
|
-
- ext/redis_client/hiredis/vendor/hiredis.h
|
73
|
-
- ext/redis_client/hiredis/vendor/hiredis.pc.in
|
74
|
-
- ext/redis_client/hiredis/vendor/hiredis_ssl-config.cmake.in
|
75
|
-
- ext/redis_client/hiredis/vendor/hiredis_ssl.h
|
76
|
-
- ext/redis_client/hiredis/vendor/hiredis_ssl.pc.in
|
77
|
-
- ext/redis_client/hiredis/vendor/net.c
|
78
|
-
- ext/redis_client/hiredis/vendor/net.h
|
79
|
-
- ext/redis_client/hiredis/vendor/read.c
|
80
|
-
- ext/redis_client/hiredis/vendor/read.h
|
81
|
-
- ext/redis_client/hiredis/vendor/sds.c
|
82
|
-
- ext/redis_client/hiredis/vendor/sds.h
|
83
|
-
- ext/redis_client/hiredis/vendor/sdsalloc.h
|
84
|
-
- ext/redis_client/hiredis/vendor/sockcompat.c
|
85
|
-
- ext/redis_client/hiredis/vendor/sockcompat.h
|
86
|
-
- ext/redis_client/hiredis/vendor/ssl.c
|
87
|
-
- ext/redis_client/hiredis/vendor/test.c
|
88
|
-
- ext/redis_client/hiredis/vendor/test.sh
|
89
|
-
- ext/redis_client/hiredis/vendor/win32.h
|
90
40
|
- lib/redis-client.rb
|
91
41
|
- lib/redis_client.rb
|
92
42
|
- lib/redis_client/command_builder.rb
|
93
43
|
- lib/redis_client/config.rb
|
94
44
|
- lib/redis_client/connection_mixin.rb
|
95
45
|
- lib/redis_client/decorator.rb
|
96
|
-
- lib/redis_client/hiredis_connection.rb
|
97
46
|
- lib/redis_client/middlewares.rb
|
98
47
|
- lib/redis_client/pooled.rb
|
99
48
|
- lib/redis_client/ruby_connection.rb
|
@@ -103,7 +52,8 @@ files:
|
|
103
52
|
- lib/redis_client/version.rb
|
104
53
|
- redis-client.gemspec
|
105
54
|
homepage: https://github.com/redis-rb/redis-client
|
106
|
-
licenses:
|
55
|
+
licenses:
|
56
|
+
- MIT
|
107
57
|
metadata:
|
108
58
|
allowed_push_host: https://rubygems.org
|
109
59
|
homepage_uri: https://github.com/redis-rb/redis-client
|