What is the difference between Phpredis and Predis in this article? Phpredis and Predis contrast, there is a certain reference value, the need for friends can refer to, I hope to help you.
Phpredis and Predis
Phpredis is a php extension written using C, and Predis is written in pure PHP.
The difference in performance is, of course, a better extension, but there is a greater difference between the two implementations, namely, the retention of the connection.
Phpredis use C in the extension to maintain a long connection php-fpm to Redis, so multiple requests on a PHP-FPM process are multiplexed on the same connection. The pconnect of Phpredis is the long connection way.
Predis uses a socket from PHP to connect to Redis, so you need to connect to Redis every time you request it.
It can be seen that the official Laravel is recommended to use Predis, because pure PHP implementation of the reason, only need to composer can be installed, very in line with the idea of laravel convenient.
Phpredis and Predis performance gaps do not span the order of magnitude, of course, to consider the specific business, if the business is very dependent on redis, and single-machine QPS need to support the larger, we recommend the use of Phpredis. If you're just using laravel to achieve a small business using Redis, it's not recommended to change Predis.