1. 程式人生 > >易學筆記-第1節:redis資料型別

易學筆記-第1節:redis資料型別

  • redis資料型別
  1. String型別

    127.0.0.1:6379> set name "xxx"

    OK

    127.0.0.1:6379> get name

    "xxx"

  2. HASH型別

    127.0.0.1:6379> HMSET myhash name1 "wys" name2 "wys2"

    OK

    127.0.0.1:6379> HGET myhash name1

    "wys"

    127.0.0.1:6379> HGET myhash name2

    "wys2"

    127.0.0.1:6379> HGET myhash name3

    (nil)

  3. List型別

    127.0.0.1:6379> lpush mylist mongodb

    (integer) 2

    127.0.0.1:6379> lpush mylist rabbitmq

    (integer) 3

    127.0.0.1:6379> lpush mylist 0

    (integer) 4

    127.0.0.1:6379> lpush mylist 0 10

    (integer) 6

    127.0.0.1:6379> lrange mylist 0 10  按插入順序倒敘

    1) "10"

    2) "0"

    3) "0"

    4) "rabbitmq"

    5) "mongodb"

    6) "redis"

  4. Set型別

    127.0.0.1:6379> sadd runoob redis mongodb rabitmq rabitmq

    (integer) 3

    127.0.0.1:6379> smembers runoob  按插入順序倒敘

    1) "rabitmq"

    2) "mongodb"

    3) "redis"

  5. zSet型別

    127.0.0.1:6379> zadd runoob3 0 redis 10 mongodb 5 rabitmq

    (integer) 3

    127.0.0.1:6379> zrangebyscore runoob3 0 1000  score 從小到大排序

    1) "redis"

    2) "rabitmq"

    3) "mongodb"