redis_cluster¶
Redis cluster module.
-
class
spicerack.redis_cluster.
RedisCluster
(cluster, config_dir, *, dry_run=True)[source]¶ Bases:
object
Class to manage a Redis Cluster.
Initialize the instance.
Parameters: -
start_replica
(datacenter, master_datacenter)[source]¶ Start the cluster replica in a datacenter from a master datacenter.
Parameters: Raises: RedisClusterError
-- on error and invalid parameters.
-
stop_replica
(datacenter)[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: tuple
-
is_master
¶ Getter to check if the current instance is a master.
Returns: True
if the instance is a master,False
otherwise.Return type: bool
-
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: tuple
-
start_replica
(master)[source]¶ Start the replica from the given master instance.
Parameters: master (spicerack.redis_cluster.RedisInstance) -- the master instance.
-