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

快捷菜单 返回顶部

php操作redis

返回上层

List数据类型函数 - 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') */


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

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

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

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