Home > Backend Development > PHP Tutorial > Implementation code for obtaining memcache values ​​in batches and returning them in key order_PHP tutorial

Implementation code for obtaining memcache values ​​in batches and returning them in key order_PHP tutorial

WBOY
Release: 2016-07-21 15:28:52
Original
1015 people have browsed it

Use the getMulti function of memcached to obtain the values ​​of the following 15 IDs in batches.
31639,33878,177410,9735,589,12076,25953,22447,15368,15358,33853,26658,26659,12477,15366

$md->getMulti($arr_id );
Return order:
line_31639,line_33878,line_177410,line_9735,line_589,line_12076,line_25953,line_22447,line_15368,line_15358,line_33853,line_26658,line_26659,line_1 2477, line_15366,

Return when one memcache is correct. When there are multiple memcaches, it is impossible to return them in order one by one.

At this time, you need to use Memcached::GET_PRESERVE_ORDER to return data in order:
$arrs = $mem->getMulti($arr_id, $cas, Memcached::GET_PRESERVE_ORDER);
Returned Order:
line_31639,line_33878,line_9735,line_589,line_22447,line_15358,line_33853,line_26658,line_177410,line_12076,line_25953,line_15368,line_26659,line_12477,line_ 15366,

Among them, if there is no hit variable , then $cas will work. $cas returns the hit variable, traverse $cas to retrieve the hit variable composition data, and then compare it with $arr_id through the array_diff function to get the difference, and then set it one by one.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323513.htmlTechArticleUse the getMulti function of memcached to obtain the values ​​of the following 15 IDs in batches. 31639,33878,177410,9735,589,12076,25953,22447,15368,15358,33853,26658,26659,12477,15366 $md-getMulti($arr_id); Return...
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