php lrem,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') */

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值