shogo82148 / Redis-Fast

fast perl binding for Redis database
https://metacpan.org/release/Redis-Fast
Other
25 stars 21 forks source link

Doesn't seem to support Redis cluster mode #99

Open iamalnewkirk opened 4 years ago

iamalnewkirk commented 4 years ago

Accessing a key located on a different shard doesn't follow the redirect and instead throws an error.

shogo82148 commented 4 years ago

Right. Redis-Fast doesn't support Redis cluster mode currently. Did you try https://metacpan.org/pod/Redis::Cluster ?

iamalnewkirk commented 4 years ago

It hasn't been updated since 2015 but I tried it anyway and it failed:

Could not connect to Redis server at 66.228.88.236:6381:9fefdfd5f9dd2d982914ff2fb866072dd4bee401:
  at /root/zing/local/lib/perl5/Redis/Cluster.pm line 669.
  Redis::Cluster::_get_node(Redis::Cluster=HASH(0x564d23e81238), "66.228.88.236:6381:9fefdfd5f9dd2d982914ff2fb866072dd4bee401") called
    at /root/zing/local/lib/perl5/Redis/Cluster.pm line 592
  Redis::Cluster::_get_master_by_slot(Redis::Cluster=HASH(0x564d23e81238), 12503) called
    at /root/zing/local/lib/perl5/Redis/Cluster.pm line 298
iamalnewkirk commented 4 years ago

I got it to work. FYI, to fix this you need to edit this line:

https://metacpan.org/source/SMSONLINE/Redis-Cluster-0.14/lib/Redis/Cluster.pm#L665

and change:

$node = join(':', @$node) if ref($node);

to this:

$node = join(':', @$node) if ref($node);
$node = join(':', (split /:/, $node)[0,1]);
Yenya commented 1 year ago

FWIW, Redis::Cluster::Fast is probably the way to go for accessing Redis cluster from Perl.

For Redis::Cluster, more places than the above one need to be patched for newer Redis protocol. See this issue for a more complete patch: https://rt.cpan.org/Ticket/Display.html?id=119851