cheprasov / php-redis-client

RedisClient is a fast, fully-functional and user-friendly client for Redis, optimized for performance. RedisClient supports the latest versions of Redis starting from 2.6 to 6.0
MIT License
126 stars 41 forks source link

Any pitfalls to STREAM_CLIENT_PERSISTENT ? #79

Open francislavoie opened 3 years ago

francislavoie commented 3 years ago

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 commented 3 years ago

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?