NAME
Redis::Cluster::Fast - A fast perl binding for Redis Cluster
SYNOPSIS
use Redis::Cluster::Fast;
my $redis = Redis::Cluster::Fast->new(
startup_nodes => [
'localhost:9000',
'localhost:9001',
'localhost:9002',
'localhost:9003',
'localhost:9004',
'localhost:9005',
],
connect_timeout => 0.05,
command_timeout => 0.05,
max_retry_count => 10,
);
$redis->set('test', 123);
# '123'
my $str = $redis->get('test');
$redis->mset('{my}foo', 'hoge', '{my}bar', 'fuga');
# get as array-ref
my $array_ref = $redis->mget('{my}foo', '{my}bar');
# get as array
my @array = $redis->mget('{my}foo', '{my}bar');
$redis->hset('mymap', 'field1', 'Hello');
$redis->hset('mymap', 'field2', 'ByeBye');
# get as hash-ref
my $hash_ref = { $redis->hgetall('mymap') };
# get as hash
my %hash = $redis->hgetall('mymap');
DESCRIPTION
Redis::Cluster::Fast is like Redis::Fast but support Redis Cluster by hiredis-cluster.
To build and use this module you need libevent-dev >= 2.x is installed on your system.
Recommend Redis 6 or higher.
Since Redis 6, it supports new version of Redis serialization protocol, RESP3. This client start to connect using RESP2 and currently it has no option to upgrade all connections to RESP3.
MICROBENCHMARK
Simple microbenchmark comparing PP and XS. The benchmark script used can be found under examples directory.
Redis::Cluster::Fast is 0.084
Redis::ClusterRider is 0.26
### mset ###
Rate Redis::ClusterRider Redis::Cluster::Fast
Redis::ClusterRider 13245/s -- -34%
Redis::Cluster::Fast 20080/s 52% --
### mget ###
Rate Redis::ClusterRider Redis::Cluster::Fast
Redis::ClusterRider 14641/s -- -40%
Redis::Cluster::Fast 24510/s 67% --
### incr ###
Rate Redis::ClusterRider Redis::Cluster::Fast
Redis::ClusterRider 18367/s -- -44%
Redis::Cluster::Fast 32879/s 79% --
### new and ping ###
Rate Redis::ClusterRider Redis::Cluster::Fast
Redis::ClusterRider 146/s -- -96%
Redis::Cluster::Fast 3941/s 2598% --
METHODS
new(%args)
Following arguments are available.
startup_nodes
Specifies the list of Redis Cluster nodes.
connect_timeout
A fractional seconds. (default: 1.0)
Connection timeout to connect to a Redis node.
command_timeout
A fractional seconds. (default: 1.0)
Specifies the timeout value for each read/write event to execute a Redis Command.
max_retry_count
A integer value. (default: 5)
The client will retry calling the Redis Command only if it successfully get one of the following error responses. MOVED, ASK, TRYAGAIN, CLUSTERDOWN.
max_retry_count
is the maximum number of retries and must be 1 or above.
<command>(@args)
To run a Redis command with arguments.
The command can also be expressed by concatenating the subcommands with underscores.
e.g. cluster_info
It does not support (Sharded) Pub/Sub family of commands and should not be run.
LICENSE
Copyright (C) plainbanana.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
AUTHOR
plainbanana <plainbanana@mustardon.tokyo>