Implementation Code returned by batch obtaining memcache values and returning them by key

Source: Internet
Author: User
The returned results for one memcache are correct. When multiple memcache instances exist, they cannot be returned in sequence.

The returned results for one memcache are correct. When multiple memcache instances exist, they cannot be returned in sequence.

Use the getMulti function of memcached to obtain the following 15 IDs in batches.
15366

$ Md-> getMulti ($ arr_id );
Returned order:
Line_000039, cosine, line_177410, line_9735, line_589, line_12076, line_25953, line_22447, line_15368, cosine, cosine, line_26658, line_26659, line_12477, cosine,

The returned results for one memcache are correct. When multiple memcache instances exist, they cannot be returned in sequence.

In this case, you must use Memcached: GET_PRESERVE_ORDER to return data in order:
$ Arrs = $ mem-> getMulti ($ arr_id, $ cas, Memcached: GET_PRESERVE_ORDER );
Returned order:
Line_000039, line_33878, line_9735, line_589, line_22447, clerk, line_33853, clerk, line_177410, line_12076, clerk, clerk, line_26659, line_12477, line_15366,

$ Cas plays a role if there are any variables that have been hit. $ Cas returns the hit variable, traverses $ cas, retrieves the hit variable to make up the data, and compares it with $ arr_id through the array_diff function, and then sets it one by one.

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.