AnyEvent-RipeRedis-Cluster
view release on metacpan or search on metacpan
lib/AnyEvent/RipeRedis/Cluster.pm view on Meta::CPAN
my $err = shift;
if ( defined $err ) {
my $err_msg = $err->message;
my $err_code = $err->code;
# error handling...
return;
}
print "$reply\n";
}
);
=head1 TRANSACTIONS
To perform the transaction you must get the master node by the key using
C<nodes> method and then execute all commands on this node. Nodes must be
discovered first.
$node = $cluster->nodes('foo');
$node->multi;
$node->set( '{foo}bar', "some\r\nstring" );
$node->set( '{foo}car', 42 );
$node->exec(
sub {
my $reply = shift;
my $err = shift;
if ( defined $err ) {
# error handling...
return;
}
# reply handling...
}
);
The detailed information about the Redis transactions can be found in
documentation on L<AnyEvent::RipeRedis> and here:
L<http://redis.io/topics/transactions>.
=head1 ERROR CODES
Every error object, passed to callback, contain error code, which can be used
for programmatic handling of errors. AnyEvent::RipeRedis::Cluster provides
constants for error codes. They can be imported and used in expressions.
use AnyEvent::RipeRedis::Cluster qw( :err_codes );
Full list of error codes see in documentation on L<AnyEvent::RipeRedis>.
=head1 DISCONNECTION
When the connection to the cluster is no longer needed you can close it in two
ways: call the method C<disconnect()> or just "forget" any references to an
AnyEvent::RipeRedis::Cluster object, but in this case the client object is
destroyed without calling any callbacks, including the C<on_disconnect>
callback, to avoid an unexpected behavior.
=head2 disconnect()
The method for disconnection. All uncompleted operations will be
aborted.
=head1 OTHER METHODS
=head2 nodes( [ $key ] [, $allow_slaves ] )
Gets particular nodes of the cluster. Nodes must be discovered first. In scalar
context method returns the first node from the list.
Getting all master nodes of the cluster:
my @master_nodes = $cluster->nodes;
Getting all nodes of the cluster, including slave nodes:
my @nodes = $cluster->nodes( undef, 1 );
Getting master node by the key:
my $master_node = $cluster->nodes('foo');
Getting nodes by the key, including slave nodes:
my @nodes = $cluster->nodes( 'foo', 1 );
=head2 refresh_interval( [ $fractional_seconds ] )
Gets or sets the C<refresh_interval> of the client. The C<undef> value resets
the C<refresh_interval> to default value.
=head2 on_error( [ $callback ] )
Gets or sets the C<on_error> callback.
=head1 SERVICE FUNCTIONS
Service functions provided by AnyEvent::RipeRedis::Cluster can be imported.
use AnyEvent::RipeRedis::Cluster qw( crc16 hash_slot );
=head2 crc16( $data )
Compute CRC16 for the specified data as defined in Redis Cluster specification.
=head2 hash_slot( $key );
Returns slot number by the key.
=head1 SEE ALSO
L<AnyEvent::RipeRedis>
=head1 AUTHOR
Eugene Ponizovsky, E<lt>ponizovsky@gmail.comE<gt>
( run in 0.912 second using v1.01-cache-2.11-cpan-5623c5533a1 )