在线工具
网站地图    收藏    合作   
<

快捷菜单 返回顶部

php操作redis

返回上层

List数据类型函数 - blPop, brPop - 命令/方法/函数

Description

Is a blocking lPop(rPop) primitive. If at least one of the lists contains at least one element, the element will be popped from the head of the list and returned to the caller. Il all the list identified by the keys passed in arguments are empty, blPop will block during the specified timeout until an element is pushed to one of those lists. This element will be popped.

lpop命令的block版本即阻塞版本。如果LIST容器中有VAULE,将会返回ARRAY('listName''element')。如果TIMEOUT参数为空,那么如果LIST为空,blPop或者brPop将或结束调用。如果设置了timeout参数,blPop或者brPop将被挂起暂停运行TIMEOUT参数的时间,在此期间如果LIST被PUSH了元素,将在TIMEOUT时间结束后,被POP出来。


Parameters

ARRAY Array containing the keys of the lists INTEGER Timeout Or STRING Key1 STRING Key2 STRING Key3 ... STRING KeynINTEGER Timeout


Return value

ARRAY array('listName', 'element')


Example

/* Non blocking feature */

$redis->lPush('key1', 'A');

$redis->delete('key2');


$redis->blPop('key1', 'key2', 10); /* array('key1', 'A') */

/* OR */

$redis->blPop(array('key1', 'key2'), 10); /* array('key1', 'A') */


$redis->brPop('key1', 'key2', 10); /* array('key1', 'A') */

/* OR */

$redis->brPop(array('key1', 'key2'), 10); /* array('key1', 'A') */


/* Blocking feature */


/* process 1 */

$redis->delete('key1');

$redis->blPop('key1', 10);

/* blocking for 10 seconds */


/* process 2 */

$redis->lPush('key1', 'A');


/* process 1 */

/* array('key1', 'A') is returned*/


来源:https://www.daixiaorui.com/

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com