222
222
223
223
See lib/redis/errors.rb for information about what exceptions are possible.
224
224
225
+ ## Timeouts
226
+
227
+ The client allows you to configure connect, read, and write timeouts.
228
+ Passing a single ` timeout ` option will set all three values:
229
+
230
+ ``` ruby
231
+ Redis .new (:timeout => 1 )
232
+ ```
233
+
234
+ But you can use specific values for each of them:
235
+
236
+ ``` ruby
237
+ Redis .new (
238
+ :connect_timeout => 0.2 ,
239
+ :read_timeout => 1.0 ,
240
+ :write_timeout => 0.5
241
+ )
242
+ ```
243
+
244
+ All timeout values are specified in seconds.
245
+
246
+ When using pub/sub, you can subscribe to a channel using a timeout as well:
247
+
248
+ ``` ruby
249
+ redis.subscribe_with_timeout(5 , " news" ) do |on |
250
+ on.message do |channel , message |
251
+ # ...
252
+ end
253
+ end
254
+ ```
255
+
256
+ If no message is received after 5 seconds, the client will unsubscribe.
257
+
258
+
225
259
## SSL/TLS Support
226
260
227
261
This library supports natively terminating client side SSL/TLS connections
@@ -234,7 +268,12 @@ You will also need to pass in an `:ssl_params => { ... }` hash used to
234
268
configure the ` OpenSSL::SSL::SSLContext ` object used for the connection:
235
269
236
270
``` ruby
237
- redis
= Redis .
new (
:url =>
" rediss://:[email protected] :6381/15" ,
:ssl_params => {
:ca_file =>
" /path/to/ca.crt" })
271
+ redis = Redis .new (
272
+ :url =>
" rediss://:[email protected] :6381/15" ,
273
+ :ssl_params => {
274
+ :ca_file => " /path/to/ca.crt"
275
+ }
276
+ )
238
277
```
239
278
240
279
The options given to ` :ssl_params ` are passed directly to the
@@ -247,7 +286,7 @@ certificate authentication (a.k.a. mutual TLS):
247
286
248
287
``` ruby
249
288
redis = Redis .new (
250
- :url =>
" rediss://:[email protected] :6381/15" ,
289
+ :url =>
" rediss://:[email protected] :6381/15" ,
251
290
:ssl_params => {
252
291
:ca_file => " /path/to/ca.crt" ,
253
292
:cert => OpenSSL ::X509 ::Certificate .new (File .read(" client.crt" )),
@@ -263,39 +302,6 @@ redis = Redis.new(
263
302
264
303
* NOTE:* SSL is only supported by the default "Ruby" driver
265
304
266
- ## Timeouts
267
-
268
- The client allows you to configure connect, read, and write timeouts.
269
- Passing a single ` timeout ` option will set all three values:
270
-
271
- ``` ruby
272
- Redis .new (:timeout => 1 )
273
- ```
274
-
275
- But you can use specific values for each of them:
276
-
277
- ``` ruby
278
- Redis .new (
279
- :connect_timeout => 0.2 ,
280
- :read_timeout => 1.0 ,
281
- :write_timeout => 0.5
282
- )
283
- ```
284
-
285
- All timeout values are specified in seconds.
286
-
287
- When using pub/sub, you can subscribe to a channel using a timeout as well:
288
-
289
- ``` ruby
290
- redis.subscribe_with_timeout(5 , " news" ) do |on |
291
- on.message do |channel , message |
292
- # ...
293
- end
294
- end
295
- ```
296
-
297
- If no message is received after 5 seconds, the client will unsubscribe.
298
-
299
305
300
306
## Expert-Mode Options
301
307
0 commit comments