How do i remove elements from a list using redis?



  • Redis lpop command: https://redis.io/commands/lpop
    Redis rpop command: https://redis.io/commands/rpop

    My redis list is:

    127.0.0.1:6379> lrange mysonglist 0 -1
    1) "help"
    2) "nowhere man"
    3) "In my life"
    4) "norwegian wood"
    5) "let it be"
    

    I want to remove the first element "help"

    127.0.0.1:6379> lpop mysonglist
    "help"
    127.0.0.1:6379> lrange mysonglist 0 -1
    1) "nowhere man"
    2) "In my life"
    3) "norwegian wood"
    4) "let it be"
    

    I want to remove the last element.

    127.0.0.1:6379> rpop mysonglist
    "let it be"
    127.0.0.1:6379> lrange mysonglist 0 -1
    1) "nowhere man"
    2) "In my life"
    3) "norwegian wood"
    

Log in to reply
 

© Lightnetics 2024