About the Pconnect and connect of Redis, problems appearing in the use

Source: Internet
Author: User
Tags pconnect

A few days ago encountered such a problem, PHP code unchanged, the requested parameters fixed. But


The first request, returns the data to be normal;

Second request, incorrect return data;

Third request, the returned data is not the same as the data returned on the second request

Fourth request, the returned data is correct and consistent with the first request returned data


Problem: PHP request Redis Code is fixed, the requested parameter is also fixed, but the return data is also different.

The code for PHP is as follows:

$redis = new Redis ();
$redis->pconnect (C (' Redis_host '), C (' Redis_port '));
$islive = $redis->hget (' Anchor_online ', $channelid);
$tmp = Json_decode ($islive, true);

Finally, change the pconnect in the code into connect. Solve the problem.

The code after the change is as follows:

$redis = new Redis ();
$redis->connect (C (' Redis_host '), C (' Redis_port '));
$islive = $redis->hget (' Anchor_online ', $channelid);
$tmp = Json_decode ($islive, true);

Multiple requests, the returned data is consistent, and is correct.


There may be other solutions that can be used to make pconnect work (no trial):



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.