PHP phpredis error when trying to pass config options while instantiating Redis class

550 views Asked by At

I have next setup:

  • PHP 8.1
  • Redis 7.0.11 - latest version
  • phpredis 5.3.7 - latest version

When I try to instantiate Redis class like this:

$redis = new Redis([
    'host' => '127.0.0.1',
    'port' => 6379,
    'connectTimeout' => 2.5,
    'auth' => 'password',
    'ssl' => ['verify_peer' => false],
    'backoff' => [
        'algorithm' => Redis::BACKOFF_ALGORITHM_DECORRELATED_JITTER,
        'base' => 500,
        'cap' => 750
    ]
]);

I get the next error:

Fatal error: Uncaught ArgumentCountError: Redis::__construct() expects exactly 0 arguments, 1 given...

Looks like constructor does not accept any arguments, but according to documentation it should.

When I try to instantiate class without config options passed, everything works as expected.

I've googled but could not find any mentioning of this error on the web, please help!

0

There are 0 answers