Skip to content

Commit 5613d6d

Browse files
committed
Formatting changes to SSL section in README.
1 parent f44f563 commit 5613d6d

File tree

1 file changed

+41
-35
lines changed

1 file changed

+41
-35
lines changed

README.md

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,40 @@ end
222222

223223
See lib/redis/errors.rb for information about what exceptions are possible.
224224

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+
225259
## SSL/TLS Support
226260

227261
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
234268
configure the `OpenSSL::SSL::SSLContext` object used for the connection:
235269

236270
```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+
)
238277
```
239278

240279
The options given to `:ssl_params` are passed directly to the
@@ -247,7 +286,7 @@ certificate authentication (a.k.a. mutual TLS):
247286

248287
```ruby
249288
redis = Redis.new(
250-
:url => "rediss://:[email protected]:6381/15",
289+
:url => "rediss://:[email protected]:6381/15",
251290
:ssl_params => {
252291
:ca_file => "/path/to/ca.crt",
253292
:cert => OpenSSL::X509::Certificate.new(File.read("client.crt")),
@@ -263,39 +302,6 @@ redis = Redis.new(
263302

264303
*NOTE:* SSL is only supported by the default "Ruby" driver
265304

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-
299305

300306
## Expert-Mode Options
301307

0 commit comments

Comments
 (0)