美文网首页
大数据开发系列之Redis

大数据开发系列之Redis

作者: 简简天天 | 来源:发表于2020-03-31 12:16 被阅读0次

nosql和sql的区别

image.png
image.png
image.png

Redis概念

image.png
image.png

Redis特点

image.png
image.png
image.png

Redis的优势

image.png image.png
image.png

Redis的适用场景

image.png
image.png
image.png

Redis的安装

image.png

Redis数据类型

image.png
image.png
  • List应用场景


    image.png
image.png
image.png
  • set
127.0.0.1:6379> sadd myset a b c
(integer) 3
127.0.0.1:6379> smembers myset
1) "b"
2) "a"
3) "c"
127.0.0.1:6379> sadd myset a d
(integer) 1
127.0.0.1:6379> smembers myset
1) "b"
2) "a"
3) "d"
4) "c"
127.0.0.1:6379> sismember myset e
(integer) 0
127.0.0.1:6379> sismemeber myset d
(error) ERR unknown command `sismemeber`, with args beginning with: `myset`, `d`, 
127.0.0.1:6379> sismember myset d
(integer) 1
127.0.0.1:6379> srem myset d
(integer) 1
127.0.0.1:6379> sadd myset1 1 2 3
(integer) 3
127.0.0.1:6379> sinter myset myset1
(empty list or set)
127.0.0.1:6379> smembers mset1
(empty list or set)
127.0.0.1:6379> sadd myset1 A B
(integer) 2
127.0.0.1:6379> smemebers mset1
(error) ERR unknown command `smemebers`, with args beginning with: `mset1`, 
127.0.0.1:6379> smembers mset1
(empty list or set)
127.0.0.1:6379> smembers myset1
1) "A"
2) "3"
3) "2"
4) "1"
5) "B"
127.0.0.1:6379> srem myset1 1 2 3
(integer) 3
127.0.0.1:6379> sinter myset myset1
(empty list or set)
127.0.0.1:6379> sunion myset myset1
1) "b"
2) "a"
3) "B"
4) "c"
5) "A"
127.0.0.1:6379> sdiff myset myset1
1) "b"
2) "a"
3) "c"
127.0.0.1:6379> sdiff myset1 myset
1) "A"
2) "B"
127.0.0.1:6379> sunionstore myset2 myset myset1
(integer) 5
127.0.0.1:6379> smembers myset2
1) "b"
2) "a"
3) "B"
4) "c"
5) "A"
127.0.0.1:6379> type myset
set

image.png
  • sorted set
127.0.0.1:6379> zadd myzset 1 a 2 b
(integer) 2
127.0.0.1:6379> zrange myzset 0 -1
1) "a"
2) "b"
127.0.0.1:6379> zrevrange myzset 0 -1
1) "b"
2) "a"
127.0.0.1:6379> zincrby myzset 10 a
"11"
127.0.0.1:6379> zrange myzset 0 -1
1) "b"
2) "a"

image.png
  • hash


    image.png
127.0.0.1:6379> hset scores english 100
(integer) 1
127.0.0.1:6379> hset scores math 110
(integer) 1
127.0.0.1:6379> hkeys scores
1) "english"
2) "math"
127.0.0.1:6379> hget scores math
"110"
127.0.0.1:6379> hmget english math
1) (nil)
127.0.0.1:6379> hmget scores english math
1) "100"
2) "110"
127.0.0.1:6379> hgetall scores
1) "english"
2) "100"
3) "math"
4) "110"

image.png
127.0.0.1:6379> hset user1 phone 1
(integer) 1
127.0.0.1:6379> hset user1 book 2
(integer) 1
127.0.0.1:6379> hset user2 phone 1
(integer) 1
127.0.0.1:6379> hgetall user1
1) "phone"
2) "1"
3) "book"
4) "2"

127.0.0.1:6379> set abc 123
OK
127.0.0.1:6379> ttl abc
(integer) -1
127.0.0.1:6379> expire abc 100
(integer) 1
127.0.0.1:6379> ttl abc
(integer) 94
127.0.0.1:6379> ttl abc
(integer) 88
127.0.0.1:6379> persist abc
(integer) 1
127.0.0.1:6379> ttl abc
(integer) -1

  • 淘汰算法


    image.png
    image.png
    image.png
    image.png

redis的高可用机制

image.png
  • 容灾


    image.png
  • 高可用


    image.png
  • Redis保证高可用的机制


    image.png
    image.png
    image.png
  • 持久化


    image.png

    rab类似snap快照模式


    image.png
  • RDB方式


    image.png
    image.png
    image.png
    image.png
    image.png
image.png
  • AOF方式


    image.png
    image.png
  • Redis主从复制


    image.png
    image.png
    image.png
  • 主从复制的过程


    image.png
    image.png
  • redis.conf配置文件参数说明


    image.png
    image.png
    image.png
    image.png
    image.png

相关文章

网友评论

      本文标题:大数据开发系列之Redis

      本文链接:https://www.haomeiwen.com/subject/ptnuuhtx.html