How do i remove multiple elements from a list using redis?



  • Redis ltrim command: https://redis.io/commands/ltrim

    The numbering to trim is explained well in the ltrim help page.

    My entire 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"
    

    Remove top two entries.

    127.0.0.1:6379> ltrim mysonglist 2 -1
    OK
    

    Verify.

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

Log in to reply
 

© Lightnetics 2024