php-redis-client icon indicating copy to clipboard operation
php-redis-client copied to clipboard

Any pitfalls to STREAM_CLIENT_PERSISTENT ?

Open francislavoie opened this issue 4 years ago • 1 comments
trafficstars

I'm just wondering if you're aware of any downsides to enabling STREAM_CLIENT_PERSISTENT for this lib, for a php-fpm or mod_php app? I don't see it recommended in the README, but I see it's mentioned as supported.

I'm evaluating which Redis client implementation I want to use, whether I'll need to use a PHP extension for performance or if this implementation would be fast enough most of the time.

Thanks!

francislavoie avatar Dec 21 '20 23:12 francislavoie

I think STREAM_CLIENT_PERSISTENT mode is bugged:

        $redis = new RedisClient([
            'server' => '127.0.0.1:6379',
            'connection' => [
                'flags' => STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT,
            ]
        ]);
PHP Warning:  fclose(): supplied resource is not a valid stream resource in /home/francis/repos/cache/vendor/cheprasov/php-redis-client/src/RedisClient/Connection/StreamConnection.php on line 98
PHP Stack trace:
PHP   1. {main}() /home/francis/repos/cache/vendor/phpunit/phpunit/phpunit:0
PHP   2. PHPUnit\TextUI\Command::main() /home/francis/repos/cache/vendor/phpunit/phpunit/phpunit:61
PHP   3. PHPUnit\TextUI\Command->run() /home/francis/repos/cache/vendor/phpunit/phpunit/src/TextUI/Command.php:162
PHP   4. PHPUnit\TextUI\TestRunner->doRun() /home/francis/repos/cache/vendor/phpunit/phpunit/src/TextUI/Command.php:206
PHP   5. RedisClient\Connection\StreamConnection->__destruct() /home/francis/repos/cache/vendor/cheprasov/php-redis-client/src/RedisClient/Connection/StreamConnection.php:0
PHP   6. fclose() /home/francis/repos/cache/vendor/cheprasov/php-redis-client/src/RedisClient/Connection/StreamConnection.php:98
PHP Warning:  fclose(): supplied resource is not a valid stream resource in /home/francis/repos/cache/vendor/cheprasov/php-redis-client/src/RedisClient/Connection/StreamConnection.php on line 98

I think it should skip calling fclose() in __destruct() if STREAM_CLIENT_PERSISTENT was set?

francislavoie avatar Dec 22 '20 00:12 francislavoie