PHP phpredis error when trying to pass config options while instantiating Redis class - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Thursday, April 20, 2023

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

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!



source https://stackoverflow.com/questions/76057790/php-phpredis-error-when-trying-to-pass-config-options-while-instantiating-redis

No comments:

Post a Comment