redis 3.3.5 → 5.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +290 -2
- data/README.md +146 -146
- data/lib/redis/client.rb +79 -541
- data/lib/redis/commands/bitmaps.rb +66 -0
- data/lib/redis/commands/cluster.rb +28 -0
- data/lib/redis/commands/connection.rb +53 -0
- data/lib/redis/commands/geo.rb +84 -0
- data/lib/redis/commands/hashes.rb +254 -0
- data/lib/redis/commands/hyper_log_log.rb +37 -0
- data/lib/redis/commands/keys.rb +437 -0
- data/lib/redis/commands/lists.rb +339 -0
- data/lib/redis/commands/pubsub.rb +54 -0
- data/lib/redis/commands/scripting.rb +114 -0
- data/lib/redis/commands/server.rb +188 -0
- data/lib/redis/commands/sets.rb +214 -0
- data/lib/redis/commands/sorted_sets.rb +884 -0
- data/lib/redis/commands/streams.rb +402 -0
- data/lib/redis/commands/strings.rb +314 -0
- data/lib/redis/commands/transactions.rb +115 -0
- data/lib/redis/commands.rb +237 -0
- data/lib/redis/distributed.rb +328 -108
- data/lib/redis/errors.rb +23 -1
- data/lib/redis/hash_ring.rb +36 -79
- data/lib/redis/pipeline.rb +69 -83
- data/lib/redis/subscribe.rb +26 -19
- data/lib/redis/version.rb +3 -1
- data/lib/redis.rb +115 -2695
- metadata +38 -218
- data/.gitignore +0 -16
- data/.travis/Gemfile +0 -11
- data/.travis.yml +0 -89
- data/.yardopts +0 -3
- data/Gemfile +0 -4
- data/Rakefile +0 -87
- data/benchmarking/logging.rb +0 -71
- data/benchmarking/pipeline.rb +0 -51
- data/benchmarking/speed.rb +0 -21
- data/benchmarking/suite.rb +0 -24
- data/benchmarking/worker.rb +0 -71
- data/examples/basic.rb +0 -15
- data/examples/consistency.rb +0 -114
- data/examples/dist_redis.rb +0 -43
- data/examples/incr-decr.rb +0 -17
- data/examples/list.rb +0 -26
- data/examples/pubsub.rb +0 -37
- data/examples/sentinel/sentinel.conf +0 -9
- data/examples/sentinel/start +0 -49
- data/examples/sentinel.rb +0 -41
- data/examples/sets.rb +0 -36
- data/examples/unicorn/config.ru +0 -3
- data/examples/unicorn/unicorn.rb +0 -20
- data/lib/redis/connection/command_helper.rb +0 -44
- data/lib/redis/connection/hiredis.rb +0 -66
- data/lib/redis/connection/registry.rb +0 -12
- data/lib/redis/connection/ruby.rb +0 -429
- data/lib/redis/connection/synchrony.rb +0 -133
- data/lib/redis/connection.rb +0 -9
- data/redis.gemspec +0 -44
- data/test/bitpos_test.rb +0 -69
- data/test/blocking_commands_test.rb +0 -42
- data/test/client_test.rb +0 -59
- data/test/command_map_test.rb +0 -30
- data/test/commands_on_hashes_test.rb +0 -21
- data/test/commands_on_hyper_log_log_test.rb +0 -21
- data/test/commands_on_lists_test.rb +0 -20
- data/test/commands_on_sets_test.rb +0 -77
- data/test/commands_on_sorted_sets_test.rb +0 -137
- data/test/commands_on_strings_test.rb +0 -101
- data/test/commands_on_value_types_test.rb +0 -133
- data/test/connection_handling_test.rb +0 -277
- data/test/connection_test.rb +0 -57
- data/test/db/.gitkeep +0 -0
- data/test/distributed_blocking_commands_test.rb +0 -46
- data/test/distributed_commands_on_hashes_test.rb +0 -10
- data/test/distributed_commands_on_hyper_log_log_test.rb +0 -33
- data/test/distributed_commands_on_lists_test.rb +0 -22
- data/test/distributed_commands_on_sets_test.rb +0 -83
- data/test/distributed_commands_on_sorted_sets_test.rb +0 -18
- data/test/distributed_commands_on_strings_test.rb +0 -59
- data/test/distributed_commands_on_value_types_test.rb +0 -95
- data/test/distributed_commands_requiring_clustering_test.rb +0 -164
- data/test/distributed_connection_handling_test.rb +0 -23
- data/test/distributed_internals_test.rb +0 -79
- data/test/distributed_key_tags_test.rb +0 -52
- data/test/distributed_persistence_control_commands_test.rb +0 -26
- data/test/distributed_publish_subscribe_test.rb +0 -92
- data/test/distributed_remote_server_control_commands_test.rb +0 -66
- data/test/distributed_scripting_test.rb +0 -102
- data/test/distributed_sorting_test.rb +0 -20
- data/test/distributed_test.rb +0 -58
- data/test/distributed_transactions_test.rb +0 -32
- data/test/encoding_test.rb +0 -18
- data/test/error_replies_test.rb +0 -59
- data/test/fork_safety_test.rb +0 -65
- data/test/helper.rb +0 -232
- data/test/helper_test.rb +0 -24
- data/test/internals_test.rb +0 -417
- data/test/lint/blocking_commands.rb +0 -150
- data/test/lint/hashes.rb +0 -162
- data/test/lint/hyper_log_log.rb +0 -60
- data/test/lint/lists.rb +0 -143
- data/test/lint/sets.rb +0 -140
- data/test/lint/sorted_sets.rb +0 -316
- data/test/lint/strings.rb +0 -260
- data/test/lint/value_types.rb +0 -122
- data/test/persistence_control_commands_test.rb +0 -26
- data/test/pipelining_commands_test.rb +0 -242
- data/test/publish_subscribe_test.rb +0 -282
- data/test/remote_server_control_commands_test.rb +0 -118
- data/test/scanning_test.rb +0 -413
- data/test/scripting_test.rb +0 -78
- data/test/sentinel_command_test.rb +0 -80
- data/test/sentinel_test.rb +0 -255
- data/test/sorting_test.rb +0 -59
- data/test/ssl_test.rb +0 -73
- data/test/support/connection/hiredis.rb +0 -1
- data/test/support/connection/ruby.rb +0 -1
- data/test/support/connection/synchrony.rb +0 -17
- data/test/support/redis_mock.rb +0 -130
- data/test/support/ssl/gen_certs.sh +0 -31
- data/test/support/ssl/trusted-ca.crt +0 -25
- data/test/support/ssl/trusted-ca.key +0 -27
- data/test/support/ssl/trusted-cert.crt +0 -81
- data/test/support/ssl/trusted-cert.key +0 -28
- data/test/support/ssl/untrusted-ca.crt +0 -26
- data/test/support/ssl/untrusted-ca.key +0 -27
- data/test/support/ssl/untrusted-cert.crt +0 -82
- data/test/support/ssl/untrusted-cert.key +0 -28
- data/test/support/wire/synchrony.rb +0 -24
- data/test/support/wire/thread.rb +0 -5
- data/test/synchrony_driver.rb +0 -88
- data/test/test.conf.erb +0 -9
- data/test/thread_safety_test.rb +0 -62
- data/test/transactions_test.rb +0 -264
- data/test/unknown_commands_test.rb +0 -14
- data/test/url_param_test.rb +0 -138
data/README.md
CHANGED
@@ -1,46 +1,17 @@
|
|
1
|
-
# redis-rb [![Build Status][
|
1
|
+
# redis-rb [![Build Status][gh-actions-image]][gh-actions-link] [![Inline docs][rdoc-master-image]][rdoc-master-link]
|
2
2
|
|
3
|
-
[
|
4
|
-
[travis-link]: http://travis-ci.org/redis/redis-rb
|
5
|
-
[travis-home]: http://travis-ci.org/
|
6
|
-
[inchpages-image]: http://inch-ci.org/github/redis/redis-rb.png
|
7
|
-
[inchpages-link]: http://inch-ci.org/github/redis/redis-rb
|
3
|
+
A Ruby client that tries to match [Redis][redis-home]' API one-to-one, while still providing an idiomatic interface.
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
[redis-home]: http://redis.io
|
12
|
-
|
13
|
-
A Ruby client that tries to match Redis' API one-to-one, while still
|
14
|
-
providing an idiomatic interface. It features thread-safety, client-side
|
15
|
-
sharding, pipelining, and an obsession for performance.
|
16
|
-
|
17
|
-
## Upgrading from 2.x to 3.0
|
18
|
-
|
19
|
-
Please refer to the [CHANGELOG][changelog-3.0.0] for a summary of the
|
20
|
-
most important changes, as well as a full list of changes.
|
21
|
-
|
22
|
-
[changelog-3.0.0]: https://github.com/redis/redis-rb/blob/master/CHANGELOG.md#300
|
5
|
+
See [RubyDoc.info][rubydoc] for the API docs of the latest published gem.
|
23
6
|
|
24
7
|
## Getting started
|
25
8
|
|
26
|
-
|
27
|
-
|
28
|
-
```
|
29
|
-
gem install redis
|
30
|
-
```
|
31
|
-
|
32
|
-
Or if you are using **bundler**, add
|
9
|
+
Install with:
|
33
10
|
|
34
11
|
```
|
35
|
-
|
12
|
+
$ gem install redis
|
36
13
|
```
|
37
14
|
|
38
|
-
to your `Gemfile`, and run `bundle install`
|
39
|
-
|
40
|
-
As of version 2.0 this client only targets Redis version 2.0 and higher.
|
41
|
-
You can use an older version of this client if you need to interface
|
42
|
-
with a Redis instance older than 2.0, but this is no longer supported.
|
43
|
-
|
44
15
|
You can connect to Redis by instantiating the `Redis` class:
|
45
16
|
|
46
17
|
```ruby
|
@@ -54,31 +25,34 @@ listening on `localhost`, port 6379. If you need to connect to a remote
|
|
54
25
|
server or a different port, try:
|
55
26
|
|
56
27
|
```ruby
|
57
|
-
redis = Redis.new(:
|
28
|
+
redis = Redis.new(host: "10.0.1.1", port: 6380, db: 15)
|
58
29
|
```
|
59
30
|
|
60
31
|
You can also specify connection options as a [`redis://` URL][redis-url]:
|
61
32
|
|
62
33
|
```ruby
|
63
|
-
redis = Redis.new(:
|
34
|
+
redis = Redis.new(url: "redis://:p4ssw0rd@10.0.1.1:6380/15")
|
64
35
|
```
|
65
36
|
|
66
|
-
|
67
|
-
|
68
|
-
By default, the client will try to read the `REDIS_URL` environment variable
|
69
|
-
and use that as URL to connect to. The above statement is therefore equivalent
|
70
|
-
to setting this environment variable and calling `Redis.new` without arguments.
|
37
|
+
The client expects passwords with special chracters to be URL-encoded (i.e.
|
38
|
+
`CGI.escape(password)`).
|
71
39
|
|
72
40
|
To connect to Redis listening on a Unix socket, try:
|
73
41
|
|
74
42
|
```ruby
|
75
|
-
redis = Redis.new(:
|
43
|
+
redis = Redis.new(path: "/tmp/redis.sock")
|
76
44
|
```
|
77
45
|
|
78
46
|
To connect to a password protected Redis instance, use:
|
79
47
|
|
80
48
|
```ruby
|
81
|
-
redis = Redis.new(:
|
49
|
+
redis = Redis.new(password: "mysecret")
|
50
|
+
```
|
51
|
+
|
52
|
+
To connect a Redis instance using [ACL](https://redis.io/topics/acl), use:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
redis = Redis.new(username: 'myname', password: 'mysecret')
|
82
56
|
```
|
83
57
|
|
84
58
|
The Redis class exports methods that are named identical to the commands
|
@@ -86,8 +60,6 @@ they execute. The arguments these methods accept are often identical to
|
|
86
60
|
the arguments specified on the [Redis website][redis-commands]. For
|
87
61
|
instance, the `SET` and `GET` commands can be called like this:
|
88
62
|
|
89
|
-
[redis-commands]: http://redis.io/commands
|
90
|
-
|
91
63
|
```ruby
|
92
64
|
redis.set("mykey", "hello world")
|
93
65
|
# => "OK"
|
@@ -96,24 +68,42 @@ redis.get("mykey")
|
|
96
68
|
# => "hello world"
|
97
69
|
```
|
98
70
|
|
99
|
-
All commands, their arguments and return values are documented
|
100
|
-
available on [
|
71
|
+
All commands, their arguments, and return values are documented and
|
72
|
+
available on [RubyDoc.info][rubydoc].
|
73
|
+
|
74
|
+
## Connection Pooling and Thread safety
|
75
|
+
|
76
|
+
The client does not provide connection pooling. Each `Redis` instance
|
77
|
+
has one and only one connection to the server, and use of this connection
|
78
|
+
is protected by a mutex.
|
79
|
+
|
80
|
+
As such it is heavilly recommended to use the [`connection_pool` gem](https://github.com/mperham/connection_pool), e.g.:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
module MyApp
|
84
|
+
def self.redis
|
85
|
+
@redis ||= ConnectionPool::Wrapper.new do
|
86
|
+
Redis.new(url: ENV["REDIS_URL"])
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
101
90
|
|
102
|
-
|
91
|
+
MyApp.redis.incr("some-counter")
|
92
|
+
```
|
103
93
|
|
104
94
|
## Sentinel support
|
105
95
|
|
106
|
-
The client is able to perform automatic
|
96
|
+
The client is able to perform automatic failover by using [Redis
|
107
97
|
Sentinel](http://redis.io/topics/sentinel). Make sure to run Redis 2.8+
|
108
98
|
if you want to use this feature.
|
109
99
|
|
110
100
|
To connect using Sentinel, use:
|
111
101
|
|
112
102
|
```ruby
|
113
|
-
SENTINELS = [{:
|
114
|
-
{:
|
103
|
+
SENTINELS = [{ host: "127.0.0.1", port: 26380 },
|
104
|
+
{ host: "127.0.0.1", port: 26381 }]
|
115
105
|
|
116
|
-
redis = Redis.new(:
|
106
|
+
redis = Redis.new(name: "mymaster", sentinels: SENTINELS, role: :master)
|
117
107
|
```
|
118
108
|
|
119
109
|
* The master name identifies a group of Redis instances composed of a master
|
@@ -130,21 +120,25 @@ but a few so that if one is down the client will try the next one. The client
|
|
130
120
|
is able to remember the last Sentinel that was able to reply correctly and will
|
131
121
|
use it for the next requests.
|
132
122
|
|
133
|
-
|
134
|
-
|
135
|
-
Redis only stores strings as values. If you want to store an object, you
|
136
|
-
can use a serialization mechanism such as JSON:
|
123
|
+
If you want to [authenticate](https://redis.io/topics/sentinel#configuring-sentinel-instances-with-authentication) Sentinel itself, you must specify the `password` option per instance.
|
137
124
|
|
138
125
|
```ruby
|
139
|
-
|
126
|
+
SENTINELS = [{ host: '127.0.0.1', port: 26380, password: 'mysecret' },
|
127
|
+
{ host: '127.0.0.1', port: 26381, password: 'mysecret' }]
|
128
|
+
|
129
|
+
redis = Redis.new(name: 'mymaster', sentinels: SENTINELS, role: :master)
|
130
|
+
```
|
140
131
|
|
141
|
-
|
142
|
-
# => OK
|
132
|
+
Also the name can be passed as an url:
|
143
133
|
|
144
|
-
|
145
|
-
|
134
|
+
```ruby
|
135
|
+
redis = Redis.new(name: "redis://mymaster", sentinels: SENTINELS, role: :master)
|
146
136
|
```
|
147
137
|
|
138
|
+
## Cluster support
|
139
|
+
|
140
|
+
[Clustering](https://redis.io/topics/cluster-spec). is supported via the [`redis-clustering` gem](cluster/).
|
141
|
+
|
148
142
|
## Pipelining
|
149
143
|
|
150
144
|
When multiple commands are executed sequentially, but are not dependent,
|
@@ -159,13 +153,24 @@ commands to Redis and gathers their replies. These replies are returned
|
|
159
153
|
by the `#pipelined` method.
|
160
154
|
|
161
155
|
```ruby
|
162
|
-
redis.pipelined do
|
163
|
-
|
164
|
-
|
156
|
+
redis.pipelined do |pipeline|
|
157
|
+
pipeline.set "foo", "bar"
|
158
|
+
pipeline.incr "baz"
|
165
159
|
end
|
166
160
|
# => ["OK", 1]
|
167
161
|
```
|
168
162
|
|
163
|
+
Commands must be called on the yielded objects. If you call methods
|
164
|
+
on the original client objects from inside a pipeline, they will be sent immediately:
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
redis.pipelined do |pipeline|
|
168
|
+
pipeline.set "foo", "bar"
|
169
|
+
redis.incr "baz" # => 1
|
170
|
+
end
|
171
|
+
# => ["OK"]
|
172
|
+
```
|
173
|
+
|
169
174
|
### Executing commands atomically
|
170
175
|
|
171
176
|
You can use `MULTI/EXEC` to run a number of commands in an atomic
|
@@ -175,9 +180,9 @@ the regular pipeline, the replies to the commands are returned by the
|
|
175
180
|
`#multi` method.
|
176
181
|
|
177
182
|
```ruby
|
178
|
-
redis.multi do
|
179
|
-
|
180
|
-
|
183
|
+
redis.multi do |transaction|
|
184
|
+
transaction.set "foo", "bar"
|
185
|
+
transaction.incr "baz"
|
181
186
|
end
|
182
187
|
# => ["OK", 1]
|
183
188
|
```
|
@@ -185,21 +190,22 @@ end
|
|
185
190
|
### Futures
|
186
191
|
|
187
192
|
Replies to commands in a pipeline can be accessed via the *futures* they
|
188
|
-
emit
|
193
|
+
emit. All calls on the pipeline object return a
|
189
194
|
`Future` object, which responds to the `#value` method. When the
|
190
195
|
pipeline has successfully executed, all futures are assigned their
|
191
196
|
respective replies and can be used.
|
192
197
|
|
193
198
|
```ruby
|
194
|
-
|
195
|
-
|
196
|
-
|
199
|
+
set = incr = nil
|
200
|
+
redis.pipelined do |pipeline|
|
201
|
+
set = pipeline.set "foo", "bar"
|
202
|
+
incr = pipeline.incr "baz"
|
197
203
|
end
|
198
204
|
|
199
|
-
|
205
|
+
set.value
|
200
206
|
# => "OK"
|
201
207
|
|
202
|
-
|
208
|
+
incr.value
|
203
209
|
# => 1
|
204
210
|
```
|
205
211
|
|
@@ -211,7 +217,7 @@ it can't connect to the server a `Redis::CannotConnectError` error will be raise
|
|
211
217
|
```ruby
|
212
218
|
begin
|
213
219
|
redis.ping
|
214
|
-
rescue
|
220
|
+
rescue Redis::BaseError => e
|
215
221
|
e.inspect
|
216
222
|
# => #<Redis::CannotConnectError: Timed out connecting to Redis on 10.0.1.1:6380>
|
217
223
|
|
@@ -246,6 +252,7 @@ All timeout values are specified in seconds.
|
|
246
252
|
When using pub/sub, you can subscribe to a channel using a timeout as well:
|
247
253
|
|
248
254
|
```ruby
|
255
|
+
redis = Redis.new(reconnect_attempts: 0)
|
249
256
|
redis.subscribe_with_timeout(5, "news") do |on|
|
250
257
|
on.message do |channel, message|
|
251
258
|
# ...
|
@@ -255,14 +262,41 @@ end
|
|
255
262
|
|
256
263
|
If no message is received after 5 seconds, the client will unsubscribe.
|
257
264
|
|
265
|
+
## Reconnections
|
258
266
|
|
259
|
-
|
267
|
+
**By default**, this gem will only **retry a connection once** and then fail, but
|
268
|
+
the client allows you to configure how many `reconnect_attempts` it should
|
269
|
+
complete before declaring a connection as failed.
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
Redis.new(reconnect_attempts: 0)
|
273
|
+
Redis.new(reconnect_attempts: 3)
|
274
|
+
```
|
275
|
+
|
276
|
+
If you wish to wait between reconnection attempts, you can instead pass a list
|
277
|
+
of durations:
|
278
|
+
|
279
|
+
```ruby
|
280
|
+
Redis.new(reconnect_attempts: [
|
281
|
+
0, # retry immediately
|
282
|
+
0.25, # retry a second time after 250ms
|
283
|
+
1, # retry a third and final time after another 1s
|
284
|
+
])
|
285
|
+
```
|
286
|
+
|
287
|
+
If you wish to disable reconnection only for some commands, you can use
|
288
|
+
`disable_reconnection`:
|
289
|
+
|
290
|
+
```ruby
|
291
|
+
redis.get("some-key") # this may be retried
|
292
|
+
redis.disable_reconnection do
|
293
|
+
redis.incr("some-counter") # this won't be retried.
|
294
|
+
end
|
295
|
+
```
|
260
296
|
|
261
|
-
|
262
|
-
when talking to Redis via a server-side proxy such as [stunnel], [hitch],
|
263
|
-
or [ghostunnel].
|
297
|
+
## SSL/TLS Support
|
264
298
|
|
265
|
-
To enable SSL support, pass the `:ssl =>
|
299
|
+
To enable SSL support, pass the `:ssl => true` option when configuring the
|
266
300
|
Redis client, or pass in `:url => "rediss://..."` (like HTTPS for Redis).
|
267
301
|
You will also need to pass in an `:ssl_params => { ... }` hash used to
|
268
302
|
configure the `OpenSSL::SSL::SSLContext` object used for the connection:
|
@@ -295,13 +329,7 @@ redis = Redis.new(
|
|
295
329
|
)
|
296
330
|
```
|
297
331
|
|
298
|
-
[
|
299
|
-
[hitch]: https://hitch-tls.org/
|
300
|
-
[ghostunnel]: https://github.com/square/ghostunnel
|
301
|
-
[OpenSSL::SSL::SSLContext documentation]: http://ruby-doc.org/stdlib-2.3.0/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html
|
302
|
-
|
303
|
-
*NOTE:* SSL is only supported by the default "Ruby" driver
|
304
|
-
|
332
|
+
[OpenSSL::SSL::SSLContext documentation]: http://ruby-doc.org/stdlib-2.5.0/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html
|
305
333
|
|
306
334
|
## Expert-Mode Options
|
307
335
|
|
@@ -315,17 +343,9 @@ redis = Redis.new(
|
|
315
343
|
Improper use of `inherit_socket` will result in corrupted and/or incorrect
|
316
344
|
responses.
|
317
345
|
|
318
|
-
##
|
346
|
+
## hiredis binding
|
319
347
|
|
320
348
|
By default, redis-rb uses Ruby's socket library to talk with Redis.
|
321
|
-
To use an alternative connection driver it should be specified as option
|
322
|
-
when instantiating the client object. These instructions are only valid
|
323
|
-
for **redis-rb 3.0**. For instructions on how to use alternate drivers from
|
324
|
-
**redis-rb 2.2**, please refer to an [older README][readme-2.2.2].
|
325
|
-
|
326
|
-
[readme-2.2.2]: https://github.com/redis/redis-rb/blob/v2.2.2/README.md
|
327
|
-
|
328
|
-
### hiredis
|
329
349
|
|
330
350
|
The hiredis driver uses the connection facility of hiredis-rb. In turn,
|
331
351
|
hiredis-rb is a binding to the official hiredis client library. It
|
@@ -335,76 +355,56 @@ extension, JRuby is not supported (by default).
|
|
335
355
|
It is best to use hiredis when you have large replies (for example:
|
336
356
|
`LRANGE`, `SMEMBERS`, `ZRANGE`, etc.) and/or use big pipelines.
|
337
357
|
|
338
|
-
In your Gemfile, include hiredis
|
358
|
+
In your Gemfile, include `hiredis-client`:
|
339
359
|
|
340
360
|
```ruby
|
341
|
-
gem "redis"
|
342
|
-
gem "hiredis"
|
361
|
+
gem "redis"
|
362
|
+
gem "hiredis-client"
|
343
363
|
```
|
344
364
|
|
345
|
-
|
365
|
+
If your application doesn't call `Bundler.require`, you may have
|
366
|
+
to require it explictly:
|
346
367
|
|
347
368
|
```ruby
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
### synchrony
|
369
|
+
require "hiredis-client"
|
370
|
+
````
|
352
371
|
|
353
|
-
|
354
|
-
This makes redis-rb work with EventMachine's asynchronous I/O, while not
|
355
|
-
changing the exposed API. The hiredis gem needs to be available as
|
356
|
-
well, because the synchrony driver uses hiredis for parsing the Redis
|
357
|
-
protocol.
|
372
|
+
This makes the hiredis driver the default.
|
358
373
|
|
359
|
-
|
360
|
-
|
361
|
-
In your Gemfile, include em-synchrony and hiredis:
|
362
|
-
|
363
|
-
```ruby
|
364
|
-
gem "redis", "~> 3.0.1"
|
365
|
-
gem "hiredis", "~> 0.4.5"
|
366
|
-
gem "em-synchrony"
|
367
|
-
```
|
368
|
-
|
369
|
-
When instantiating the client object, specify synchrony:
|
374
|
+
If you want to be certain hiredis is being used, when instantiating
|
375
|
+
the client object, specify hiredis:
|
370
376
|
|
371
377
|
```ruby
|
372
|
-
redis = Redis.new(:
|
378
|
+
redis = Redis.new(driver: :hiredis)
|
373
379
|
```
|
374
380
|
|
375
381
|
## Testing
|
376
382
|
|
377
|
-
This library is tested
|
378
|
-
|
383
|
+
This library is tested against recent Ruby and Redis versions.
|
384
|
+
Check [Github Actions][gh-actions-link] for the exact versions supported.
|
385
|
+
|
386
|
+
## See Also
|
379
387
|
|
380
|
-
|
381
|
-
* MRI 1.9.3 (drivers: ruby, hiredis, synchrony)
|
382
|
-
* MRI 2.0 (drivers: ruby, hiredis, synchrony)
|
383
|
-
* MRI 2.1 (drivers: ruby, hiredis, synchrony)
|
384
|
-
* MRI 2.2 (drivers: ruby, hiredis, synchrony)
|
385
|
-
* MRI 2.3 (drivers: ruby, hiredis, synchrony)
|
386
|
-
* JRuby 1.7 (1.8 mode) (drivers: ruby)
|
387
|
-
* JRuby 1.7 (1.9 mode) (drivers: ruby)
|
388
|
+
- [async-redis](https://github.com/socketry/async-redis) — An [async](https://github.com/socketry/async) compatible Redis client.
|
388
389
|
|
389
390
|
## Contributors
|
390
391
|
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
* Taylor Weibley
|
396
|
-
* Matthew Clark
|
397
|
-
* Brian McKinney
|
398
|
-
* Luca Guidi
|
399
|
-
* Salvatore Sanfilippo
|
400
|
-
* Chris Wanstrath
|
401
|
-
* Damian Janowski
|
402
|
-
* Michel Martens
|
403
|
-
* Nick Quaranto
|
404
|
-
* Pieter Noordhuis
|
405
|
-
* Ilya Grigorik
|
392
|
+
Several people contributed to redis-rb, but we would like to especially
|
393
|
+
mention Ezra Zygmuntowicz. Ezra introduced the Ruby community to many
|
394
|
+
new cool technologies, like Redis. He wrote the first version of this
|
395
|
+
client and evangelized Redis in Rubyland. Thank you, Ezra.
|
406
396
|
|
407
397
|
## Contributing
|
408
398
|
|
409
399
|
[Fork the project](https://github.com/redis/redis-rb) and send pull
|
410
|
-
requests.
|
400
|
+
requests.
|
401
|
+
|
402
|
+
|
403
|
+
[rdoc-master-image]: https://img.shields.io/badge/docs-rdoc.info-blue.svg
|
404
|
+
[rdoc-master-link]: https://rubydoc.info/github/redis/redis-rb
|
405
|
+
[redis-commands]: https://redis.io/commands
|
406
|
+
[redis-home]: https://redis.io
|
407
|
+
[redis-url]: https://www.iana.org/assignments/uri-schemes/prov/redis
|
408
|
+
[gh-actions-image]: https://github.com/redis/redis-rb/workflows/Test/badge.svg
|
409
|
+
[gh-actions-link]: https://github.com/redis/redis-rb/actions
|
410
|
+
[rubydoc]: https://rubydoc.info/gems/redis
|