zoukankan      html  css  js  c++  java
  • LREM key count value

    LREM key count value

    Removes the first count occurrences of elements equal to value from the list stored at key. The count argument influences the operation in the following ways:

    • count > 0: Remove elements equal to value moving from head to tail.
    • count < 0: Remove elements equal to value moving from tail to head.
    • count = 0: Remove all elements equal to value.

    For example, LREM list -2 "hello" will remove the last two occurrences of"hello" in the list stored at list.

    Note that non-existing keys are treated like empty lists, so when key does not exist, the command will always return 0.

    Return value

    Integer reply: the number of removed elements.

    Examples

    redis> RPUSH mylist "hello"
    (integer) 1
    redis> RPUSH mylist "hello"
    (integer) 2
    redis> RPUSH mylist "foo"
    (integer) 3
    redis> RPUSH mylist "hello"
    (integer) 4
    redis> LREM mylist -2 "hello"
    (integer) 2
    redis> LRANGE mylist 0 -1
    1) "hello"
    2) "foo"
    redis>
  • 相关阅读:
    2018-11-28笔记
    2018-11-27笔记
    2018-11-26笔记
    DBUtils和连接池
    动态页面技术(JSP/EL/JSTL)
    会话技术Cookie&Session
    JavaEE—— HttpServletRequest
    JavaEE—— HttpServletResponse
    JavaWeb核心之Servlet
    JavaEE——HTTP协议和Tomcat服务器
  • 原文地址:https://www.cnblogs.com/softidea/p/5945588.html
Copyright © 2011-2022 走看看