第三章-Redis数据类型

Redis五大数据类型

  • Redis字符串(String)
  • Redis列表(List)
  • Redis集合(Set)
  • Redis哈希(Hash)
  • Redis集合ZSet(sorted set)

常见redis操作命令网址

http://redisdoc.com/

image-20191106170431343

Redis键(key)

image-20191106170513773

Redis字符串(String)

image-20191106170553229

getrange/setrange:

image-20191106170619950

Redis列表(List)

单值多value。

案例:

  1. lpush/rpush/lrange

    image-20191106170755485

  2. lpop/rpop

    image-20191106170810909

  3. lrem

    image-20191106170825978

  4. lset key index value

    image-20191106170839740

  5. linsert key before/after 值1 值2

    image-20191106170850062

  6. 性能总结

    image-20191106170902286

Redis集合(Set)

单值多value。

案例:

image-20191106170948046

sadd/smembers/sismember:

image-20191106171015662

数学集合类:

  • 差集
  • 交集
  • 并集

image-20191106171059136

Redis哈希(Hash)

image-20191106171227111

Redis集合ZSet(sorted set)

image-20191106171537466

  1. zadd/zrange

    image-20191106171624839

  2. zrangebyscore key 开始score 结束score

    image-20191106171723552

  3. zcard/zcount/zscore

    image-20191106171735269

  4. zrevrank/zrevrange

    image-20191106171747580

  5. zrevrangebyscore key 开始score 结束score

    image-20191106171756934