redispace is a Redis client based on redis-py.
Redis block that is composited with RedisNode.
Parameters: | nodes (collections.Mapping or list) – the collection of RedisNode |
---|
If list is given for nodes, it converts the list to dict internally.
Proxy for method of RedisBlock.client.:
Same as RedisNode.execute().
Parameters: | command (basestring) – the name of RedisBlock.client‘s method to call |
---|
Pooling RedisNode and fetch one in turn.
>>> rb.get_node_by_rotation()
('node_1', <redispace.RedisNode object at 0x1376990>)
>>> rb.get_node_by_rotation()
('node_0', <redispace.RedisNode object at 0x1376810>)
>>> rb.get_node_by_rotation()
('node_1', <redispace.RedisNode object at 0x1376990>)
>>> rb.get_node_by_rotation()
('node_0', <redispace.RedisNode object at 0x1376810>)
Parameters: | with_name (bool) – the boolean value whether this method returns node with its name or not |
---|---|
Returns: | the redis node that is in its turn |
Return type: | tuple or RedisNode |
Redis node class using redis.StrictRedis.
Read-only attribute to get the redis client bound to self.
Returns: | the redis client that is bound to self. |
---|---|
Return type: | redis.StrictRedis |
Proxy for method of RedisNode.client.
node = RedisNode()
result = node.execute('set', 'key', 'value')
value = node.execute('get', 'key')
# is equivalent to:
result = node.client.set('key', 'value')
value = node.client.get('key')
Parameters: | command (basestring) – the name of RedisNode.client‘s method to call |
---|
Read-only attribute to get host of bound redis.
Returns: | the host of bound redis server |
---|---|
Return type: | basestring |
Read-only attribute to get port of bound redis.
Returns: | the port of bound redis server |
---|---|
Return type: | numbers.Integral |
Shards data into RedisBlock and distributes operations to RedisNode.