代潇瑞博客

lRem 命令/方法/函数

Removes the first count occurences of the value element from the list. If count is zero, all the matching elements are removed. If count is negative, elements are removed from tail to head.

IRem,IRemove函数,首先要去判断count参数,如果count参数为0,那么所有符合删除条件的元素都将被移除。如果count参数为整数,将从左至右删除count个符合条件的元素,如果为负数则从右至左删除count个符合条件的元素。


Note: The argument order is not the same as in the Redis documentation. This difference is kept for compatibility reasons.

函数参数的顺序不一定要一致,这样做是为了保持兼容性。


Parameters

key

value

count


Return value

LONG the number of elements to remove

BOOL FALSE if the value identified by key is not a list.


Example

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

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

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

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

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


$redis->lRange('key1', 0, -1); /* array('A', 'A', 'C', 'B', 'A') */

$redis->lRem('key1', 'A', 2); /* 2 */

$redis->lRange('key1', 0, -1); /* array('C', 'B', 'A') */

【相关命令】

触屏版 | 电脑版

Copyright © 2013 代潇瑞博客手机版

QQ: 446673330

粤ICP备13071969号-1