Project

redisent

0.01
No commit activity in last 3 years
No release in over 3 years
Redisent is a wrapper for the Redis client that fetches configuration details from sentinels.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0

Runtime

~> 1.5
 Project Readme

Redisent

Sentinel aware Redis client.

Description

Redisent is a wrapper for the Redis client that fetches configuration details from sentinels.

Usage

Instead of passing a Redis URL, you have to pass an array with the URLs of your Redis sentinels as the first parameter, then the name of your master server (as defined in the sentinels configuration) as the second parameter, and finally a hash of options to be used when connecting to the master.

# List of sentinels.
sentinels = ["localhost:27379",
             "localhost:27380",
             "localhost:27381"]

# Master server name as defined in sentinel.conf.
master = "server-1"

redis = Redisent.new(hosts: sentinels, name: master)

If the sentinels can't be reached you will get the exception Redisent::UnreachableHosts. If the master name is unknown, you will get the exception Redisent::UnknownMaster.

Failover

In case of a failover, it is important that the clients don't engage with the failed master even if it's restored. For that reason, clients must connect to the Redis sentinels in order to get the address of the promoted master, and the way to accomplish that is by using Redisent.new each time a reconnection is needed.

Installation

You can install it using rubygems:

$ gem install redisent