Redis-Cluster-Fast
view release on metacpan or search on metacpan
[](https://github.com/plainbanana/Redis-Cluster-Fast/actions) [](https://metacpan.org/rel...
# NAME
Redis::Cluster::Fast - A fast perl binding for Redis Cluster
# SYNOPSIS
use Redis::Cluster::Fast;
Redis::Cluster::Fast::srandom(100);
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](https://github.com/shogo82148/Redis-Fast) but support Redis Cluster by [hiredis-cluster](https://github.com/Nordix/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](https://github.com/antirez/RESP3/blob/master/spec.md).
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.
Each operation was executed 100,000 times, and the execution time was measured in milliseconds.
+--------------------------------+-------+-------+-------+-------+-------+
| Operation | P50 | P80 | P95 | P99 | P100 |
+--------------------------------+-------+-------+-------+-------+-------+
| get_pp | 0.028 | 0.032 | 0.036 | 0.050 | 0.880 |
| get_xs | 0.020 | 0.023 | 0.025 | 0.044 | 0.881 |
| get_xs_pipeline | 0.014 | 0.015 | 0.018 | 0.021 | 0.472 |
| get_xs_pipeline_batched_100 | 0.003 | 0.003 | 0.004 | 0.074 | 0.323 |
| set_pp | 0.028 | 0.032 | 0.037 | 0.051 | 2.014 |
| set_xs | 0.021 | 0.024 | 0.027 | 0.047 | 0.729 |
| set_xs_pipeline | 0.014 | 0.016 | 0.018 | 0.021 | 0.393 |
| set_xs_pipeline_batched_100 | 0.003 | 0.004 | 0.005 | 0.073 | 0.379 |
+--------------------------------+-------+-------+-------+-------+-------+
c.f. https://github.com/plainbanana/Redis-Cluster-Fast-Benchmarks
# METHODS
## srandom($seed)
hiredis-cluster uses [random()](https://linux.die.net/man/3/random) to select a node used for requesting cluster topology.
( run in 0.783 second using v1.01-cache-2.11-cpan-501a3233654 )