Automatic deserialization of Tokyo tyrant in PHP

Source: Internet
Author: User

I encountered a problem trying to use Tokyo tyrant a while ago,
Using the memcache interface in PHP, data is not automatically deserialized when retrieved. For example, an array (1, 2, 3, 4, 5) is generated as 'a: 5: {I: 0; I: 1; I: 1; I: 2; I: 2; i: 3; I: 3; I: 4; I: 4; I: 5.

Use
Wireshark traces and finds a byte difference from the data returned by the standard memcached. I checked out memcached.
Protocol, it is found that this byte is the flag of a client. This flag is placed during storage, and will be returned when it is retrieved. PHP memcache
The extension should use this byte to indicate whether it is Php data. Deserialization is performed if a match is found. Comparison between Tokyo tyrant
OfSource codeIt is found that it ignores this flag bit during access (in fact, it ignores some other things, such as the expiration time, and only uses the key and Value
And their length.

In the past, I decided to change to Tokyo tyrant and made a patch. But just like xdanger
Said, this method is not good. I did not perform the test carefully before, but I tried several different types, which is indeed a problem. So I want to change PHP again.
. Make it Serial No matter what type of storage. It seems that the problem of reverse serial number is solved. In this way, the original version of the client can be read normally, but once the original version of the client has been put into the regular value, it will be faulty. At the same time, the client and the server are modified. In addition, the compression problem is still not solved. It seems that this problem is really difficult.

PHP client patch, modify memcache. c
Http://syre.blogbus.com/files/12229540080.diff

Tokyo tyrant patch to modify ttserver. c
Http://syre.blogbus.com/files/12227686210.diff

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.