Home > Backend Development > PHP Tutorial > What is the difference between phpredis and predis? Comparison of the differences between phpredis and predis

What is the difference between phpredis and predis? Comparison of the differences between phpredis and predis

不言
Release: 2023-04-03 19:00:01
Original
6304 people have browsed it

This article brings you what is the difference between phpredis and predis? The comparison of the differences between phpredis and predis has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Recommended manual: php complete self-study manual

##phpredis and predis

phpredis is a PHP extension written in C, and predis is written in pure PHP.

The difference in performance is of course better expansion, but in fact there is a bigger difference between the two implementations, which is the maintenance of connections.

1. phpredis uses c in the extension to maintain a long connection from php-fpm to redis, so multiple requests on a php-fpm process reuse the same connection. Pconnect of phpredis is a long connection method.

2. Predis uses PHP socket to connect to redis, so you need to connect to redis every time you request it.

It can be seen that Laravel officially recommends using predis. Because of the pure PHP implementation, only composer can be installed, which is very consistent with Laravel's convenient thinking.

The performance gap between phpredis and predis does not span orders of magnitude. Of course, the specific business must be considered. If the business relies heavily on redis and the single-machine QPS needs to support a relatively large amount, it is recommended to use phpredis. If you only use laravel and redis to implement small-scale business, it is recommended not to change predis.

Recommended related articles: 1.
Performance comparison between PhpRedis and Predis (example)2.
Basic method of operating Redis in PHP3.
php-redis Summary of commonly used commands
Related video recommendations:1.
Dugu Jiujian(4)_PHP video tutorial

The above is the detailed content of What is the difference between phpredis and predis? Comparison of the differences between phpredis and predis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template