GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
RedisDB::Cluster(3) User Contributed Perl Documentation RedisDB::Cluster(3)

RedisDB::Cluster - client for redis cluster

    my $cluster = RedisDB::Cluster->new( startup_nodes => \@nodes );
    $cluster->set( 'foo', 'bar' );
    my $res = $cluster->get('foo');

This module allows you to access redis cluster.

create a new connection to cluster. Startup nodes should contain array of hashes that contains addresses of some nodes in the cluster. Each hash should contain 'host' and 'port' elements. Constructor will try to connect to nodes from the list and from the first node to which it will be able to connect it will retrieve information about all cluster nodes and slots mappings.

sends command to redis and returns the reply. It determines the cluster node to send command to from the first key in @args, sending commands that does not include key as an argument is not supported. If @args contains several keys, all of them should belong to the same slot, otherwise redis-server will return an error if some of the keys are stored on a different node.

Module also defines wrapper methods with names matching corresponding redis commands, so you can use

    $cluster->set( "foo", "bar" );
    $cluster->inc("baz");

instead of

    $cluster->execute( "set", "foo", "bar" );
    $cluster->execute( "inc", "baz" );

return RedisDB object that is connected to some node of the cluster. Note, that in most cases this method will return the same connection every time.

return RedisDB object connected to cluster node that is master node for the given slot. %params are passed to RedisDB constructor as is. This method is using information about mappings between slots and nodes that is cached by RedisDB::Cluster object, if there were changes in cluster configuration since the last time that information has been obtained, then the method will return RedisDB object connected to a wrong server, you can detect that situation by checking results returned by server, it should return MOVED or ASK error if you accessing the wrong server or slot is being migrated. Each time you call this method a new RedisDB object is returned and consequently a new connection is being established, so it is not something very fast.

same as node_for_slot but accepts key instead of slot number as the first argument. Internally just calculates the slot number and then invokes node_for_slot method.

The following methods can be used for cluster management -- to add or remove a node, or migrate slot from one node to another.

attach node with the specified $address to the cluster. If $master_id is specified, the new node is configured as a replica of the master with the specified ID, otherwise it will be a master node itself. Address should be specified as a hash containing host and port elements.

migrates specified slot to the given $destination_node from the current node responsible for this slot. Destinations node should be specified as a hash containing host and port elements. For details check "Cluster live reconfiguration" section in the Redis Cluster Specification <http://redis.io/topics/cluster-spec>.

removes node from the cluster. If the node is a slave, it simply shuts the node down and sends CLUSTER FORGET command to all other cluster nodes. If the node is a master node, the method first migrates all slots from it to other nodes.

compute crc16 for the specified buffer as defined in redis cluster specification

return slot number for the given $key

Pavel Shaydo, "<zwon at cpan.org>"

Copyright 2011-2016 Pavel Shaydo.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.

2016-11-16 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.