Closed vsespb closed 6 years ago
I think that because the every
parameter is too short.
the unit of every
is micro second, not milli second.
i've tried with 100_000. same:
$ perl 1.pl
works
works
works
works
works
works
works
works
works
works
works
works
works
err: Could not connect to Redis server at localhost:6379 at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
err: Not connected to any server at /usr/local/lib/x86_64-linux-gnu/perl/5.24.1/Redis/Fast.pm line 265.
^C
$ cat 1.pl
use strict;
use warnings;
use Redis::Fast;
my $redis = Redis::Fast->new(
server => 'localhost:6379',
reconnect=>20,
every => 100_000,
cnx_timeout => 10,
read_timeout => 3,
write_timeout => 3,
);
while() {
eval {
$redis->get(42);
print "works\n";
} or do {
print "err: $@"
};
sleep 1;
}
I fixed this issue, and released Redis::Fast v0.21. Please try it.
so, script:
will print the following:
if I stop redis server (after that first
err: Could not connect to Redis server
line emited), and then start it in a few minutes (after all reconnect attemts exhaused)$redis
connect does not work even with live Redis server, it still emits "err: Not connected to any server".In contrast behaviour with
Redis
module:i.e. the handle still can be used after redis server up.
Not sure which behaviour is more correct, but the fact is they differs.
Also our use case when we prefer
Redis
module behaviour: we have long running daemons and if redis server down for several minutes we have to restart all daemons and cannot use reconnect feature, or we have to write special code in everyeval
after which we would want to connect again.