Skip to content

Commit

Permalink
Update readme to include how to configure sentinel
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvCW committed Aug 19, 2023
1 parent ded261b commit 0596901
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,29 @@ lock_manager.get_remaining_ttl_for_resource(resource)

## Redis client configuration

`Redlock::Client` expects URLs or Redis objects on initialization. Redis objects should be used for configuring the connection in more detail, i.e. setting username and password.
`Redlock::Client` expects URLs, or configurations or Redis objects on initialization. Redis objects should be used for configuring the connection in more detail, i.e. setting username and password.

```ruby
servers = [ 'redis://localhost:6379', RedisClient.new(:url => 'redis://someotherhost:6379') ]
redlock = Redlock::Client.new(servers)
```

Redlock works seamlessly with [redis sentinel](http://redis.io/topics/sentinel), which is supported in redis 3.2+.
To utilize `Redlock::Client` with sentinels you can pass an instance of `RedisClient` or just a configuration hash as part of the servers array during initialization.

```ruby
config = {
name: "mymaster",
sentinels: [
{ host: "127.0.0.1", port: 26380 },
{ host: "127.0.0.1", port: 26381 },
],
role: :master
}
client = RedisClient.sentinel(**config).new_client
servers = [ config, client ]
redlock = Redlock::Client.new(servers)
```
Redlock supports the same configuration hash as `RedisClient`.

## Redlock configuration

Expand Down

0 comments on commit 0596901

Please sign in to comment.