redis_cluster¶
Redis cluster module.
-
class
spicerack.redis_cluster.
RedisCluster
(cluster: str, config_dir: str, *, dry_run: bool = True)[source]¶ Bases:
object
Class to manage a Redis Cluster.
Initialize the instance.
- Parameters
-
start_replica
(datacenter: str, master_datacenter: str) → None[source]¶ Start the cluster replica in a datacenter from a master datacenter.
- Parameters
- Raises
RedisClusterError -- on error and invalid parameters.
-
stop_replica
(datacenter: str) → None[source]¶ Stop the cluster replica in a datacenter.
- Parameters
datacenter (str) -- the datacenter on which to stop the replica.
- Raises
RedisClusterError -- on error.
-
exception
spicerack.redis_cluster.
RedisClusterError
[source]¶ Bases:
spicerack.exceptions.SpicerackError
Custom exception class for errors in the RedisCluster class.
-
class
spicerack.redis_cluster.
RedisInstance
(**kwargs)[source]¶ Bases:
object
Class to manage a Redis instance, a simple wrapper around redis.StrictRedis.
Initialize the instance.
- Parameters
**kwargs (mixed) -- arbitrary keyword arguments, to be passed to the redis.StrictRedis constructor.
-
info
¶ Getter to know the detail of this instance.
- Returns
a 2-element tuple with (host/IP, port) of the instance.
- Return type
-
is_master
¶ Getter to check if the current instance is a master.
-
master_info
¶ Getter to know the master of this instance.
- Returns
a 2-element tuple with (host/IP, port) of the master instance. If there is no master configured (None, None) is returned.
- Return type
-
start_replica
(master: spicerack.redis_cluster.RedisInstance) → None[source]¶ Start the replica from the given master instance.
- Parameters
master (spicerack.redis_cluster.RedisInstance) -- the master instance.