Sitelet https://github.com/phpredis/phpredis/issues/1238
Skip to content

Treat an empty "persistent_id" the same as omitting this parameter #1238

Description

@steffenweber

There does not seem to be any value that can be used for $persistent_id in

$redis->pconnect($host, $port, $timeout, $persistent_id);

such that Phpredis re-uses a connection established by omitting this parameter:

$redis->pconnect($host, $port, $timeout);

I've tried to pass '', null, true, false and 0. All are treated differently than omitting the parameter completely, i.e. a new connection is established.

Expected behaviour

When I call the pconnect method with persistent_id = '' then Phpredis should behave the same as if I omitted this parameter (because the empty string is documented as the default value).

Actual behaviour

Phpredis treats persistent_id = '' differently than omitting this parameter.

I'm seeing this behaviour on

  • OS: Linux
  • Redis: 4.0.1
  • PHP: 7.1.9
  • phpredis: 3.1.3 and 3.1.4 RC1

Steps to reproduce, backtrace or example script

<?php
$redis1 = new \Redis();
$redis1->pconnect('127.0.0.1', 6379, 0.0);

$redis2 = new \Redis();
$redis2->pconnect('127.0.0.1', 6379, 0.0, '');

echo getmypid() . "\n";
sleep(60);

Then, in another console tab, run ss -p | grep "pid=PID" (replace PIDwith the output of the script) to check how many Redis connections the script has established. Expected value: 1. Actual value: 2.

I've checked

  • There is no similar issue from other users
  • Issue isn't fixed in develop branch

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions