redispace — redispace

redispace is a Redis client based on redis-py.

class redispace.RedisBlock(nodes)

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.

execute(command, *args, **kwargs)

Proxy for method of RedisBlock.client.:

Same as RedisNode.execute().

Parameters:command (basestring) – the name of RedisBlock.client‘s method to call
get_node_by_rotation(with_name=True)

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
class redispace.RedisNode(host='localhost', port=6379, **config)

Redis node class using redis.StrictRedis.

client

Read-only attribute to get the redis client bound to self.

Returns:the redis client that is bound to self.
Return type:redis.StrictRedis
execute(command, *args, **kwargs)

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
host

Read-only attribute to get host of bound redis.

Returns:the host of bound redis server
Return type:basestring
port

Read-only attribute to get port of bound redis.

Returns:the port of bound redis server
Return type:numbers.Integral
class redispace.Redispace

Shards data into RedisBlock and distributes operations to RedisNode.

Previous topic

redispace

This Page