Php uses memcache to store session data loss problems

Source: Internet
Author: User
Php uses memcache to store session data loss. first test the code. you can also test index. php & lt ;? Phpsession_start (); $ method & nbsp; = & nbsp; $ _ GET ['method']; if (isset ($ _ SESSION ['Me php uses memcache to store session data loss problem
Test the code first. you can also test it.
Index. php
 session_start();
$method = $_GET['Method'];
if(isset($_SESSION['Method'])){
$_SESSION['Method'] = $_SESSION['Method'].$method;
}else{
$_SESSION['Method'] =$method;
}
?>

Clent.html




Untitled Document

Script
Script
Script
Script
Script
Script




After that, you can print out the SESSION and check that data is often lost. SESSION records are often incomplete. I don't know why. please explain it with experts.

Other configurations are attached below.
Libevent-2.0.18-stable.tar.gz server
Memcached-1.4.13.tar.gz server
Memcache-2.2.6.tgz PHP client



PHP. ini
Session. save_path = "tcp: // 192.168.234.234: 11211"
Session. save_handler = memcache

PHP components
Php_memcache.dll version 2.2.6.0:
------ Solution --------------------
Reference:
... Of course, the problem was discovered only after reading ..
I traversed the data in memcache, but it was not written in. It is not unread.
You just don't understand what I mean.
I mean: it's good to read it right away. it means it's written.
What do you think?
------ Solution --------------------
You should consider the browser's almost concurrent requests. your new value is set based on the value read several milliseconds ago. At this time, it is entirely possible that a new value is successfully inserted. If you insert a new value, the new value written in the previous step is overwritten immediately. Therefore, data loss is normal.
You can write a test on the client or server to compare the effect of one second of pause and concurrent execution.
------ Solution --------------------

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.