• Redis 常用命令学四:列表类型命令


    1.在列表两端增加值的命令

    127.0.0.1:6379> lpush 1
    (error) ERR wrong number of arguments for 'lpush' command
    127.0.0.1:6379> lpush rs 1
    (integer) 1
    127.0.0.1:6379> lpush rs 2 3
    (integer) 3
    127.0.0.1:6379> rpush rs 4 5 6
    (integer) 6
    

    2.查看某个范围内的值

    127.0.0.1:6379> LRANGE rs 2 4
    1) "1"
    2) "4"
    3) "5"
    127.0.0.1:6379> LRANGE rs 0 7
    1) "3"
    2) "2"
    3) "1"
    4) "4"
    5) "5"
    6) "6"
    127.0.0.1:6379> LRANGE rs -3 -1
    1) "4"
    2) "5"
    3) "6
    

    3.从列表中删除值

    127.0.0.1:6379> LPOP rs
    "3"
    127.0.0.1:6379> RPOP rs
    "6"
    

    4.获取列表长度

    127.0.0.1:6379> LLEN rs
    (integer) 4
    

    5.从左边删除3个为4的值,原来列表中只有一个

    127.0.0.1:6379> LREM rs 3 4
    (integer) 1
    

    6.获得指定的索引的元素值

    127.0.0.1:6379> LINDEX rs 2
    "5"
    

    7.为指定的索引赋值

    127.0.0.1:6379> LSET rs 2 100
    OK
    127.0.0.1:6379> LINDEX rs 2
    "100"
    
  • 相关阅读:
    作业3.14下
    作业3.14上
    作业3.13 下
    作业 3.13上
    2017.3.10上午
    2017.3.9上午
    2017.3.23-morning
    2017.3.22-morning
    2017.3.21-afternoon
    2017.3.21-morning
  • 原文地址:https://www.cnblogs.com/qiaojushuang/p/8128148.html
Copyright © 2020-2023  润新知