REDIS
2020-08-05 14:09:22 0 举报
AI智能生成
redis思维导图
作者其他创作
大纲/内容
数据持久化选项<br>
快照(snapshotting)
两种快照执行命令<br>
BGSAVE
SAVE
只追加文件AOF(append-only file)<br>
appendfsync可选值
always
everysec
no
压缩/重写AOF文件
BGREWRITEAOF
复制<br>
<br>
设置从服务器的两种方式<br>
配置选项:SLAVEOF host port<br>
发送SLAVEOF host port命令<br>
主从链
处理系统故障<br>
验证快照文件和AOF文件<br>
redis-check-aof
redis-check-dump
更换故障主服务器
<br>
内存淘汰机制<br>
内存淘汰策略<br>
<strong style="margin: 0px; padding: 0px; max-width: 100%; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.5440000295639038px; text-align: justify; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-size-adjust: 100%; box-sizing: border-box !important; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; color: inherit; line-height: inherit; font-size: 15px; box-sizing: border-box !important; word-wrap: break-word !important;">noeviction</span></strong><br>
<strong style="margin: 0px; padding: 0px; max-width: 100%; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.5440000295639038px; text-align: justify; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-size-adjust: 100%; box-sizing: border-box !important; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; color: inherit; line-height: inherit; font-size: 15px; box-sizing: border-box !important; word-wrap: break-word !important;">allkeys-lru</span></strong><br>
<strong style="margin: 0px; padding: 0px; max-width: 100%; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.5440000295639038px; text-align: justify; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-size-adjust: 100%; box-sizing: border-box !important; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; color: inherit; line-height: inherit; font-size: 15px; box-sizing: border-box !important; word-wrap: break-word !important;">allkeys-random</span></strong><br>
<strong style="margin: 0px; padding: 0px; max-width: 100%; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.5440000295639038px; text-align: justify; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-size-adjust: 100%; box-sizing: border-box !important; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; color: inherit; line-height: inherit; font-size: 15px; box-sizing: border-box !important; word-wrap: break-word !important;">volatile-lru</span></strong><br>
<strong style="margin: 0px; padding: 0px; max-width: 100%; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.5440000295639038px; text-align: justify; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-size-adjust: 100%; box-sizing: border-box !important; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; color: inherit; line-height: inherit; font-size: 15px; box-sizing: border-box !important; word-wrap: break-word !important;">volatile-random</span></strong><br>
<strong style="margin: 0px; padding: 0px; max-width: 100%; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; letter-spacing: 0.5440000295639038px; text-align: justify; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-size-adjust: 100%; box-sizing: border-box !important; word-wrap: break-word !important;"><span style="margin: 0px; padding: 0px; max-width: 100%; color: inherit; line-height: inherit; font-size: 15px; box-sizing: border-box !important; word-wrap: break-word !important;">volatile-ttl</span></strong><br>
淘汰算法<br>
LRU
LFU<br>
数据结构<br>
基础数据结构
字符串STRING
SDS
结构<br>
优点<br>
常数复杂度获取字符串长度O(1)
防止缓冲区溢出(对SDS修改时,会先检查空间是否满足修改所需的要求,如果不满足,会自动扩展SDS的空间)
减少修改字符串时带来的内存重分配次数
通过free,可以实现空间预分配和惰性空间释放两种优化策略
二进制安全
兼容部分C字符串函数<br>
集合SET
有序集合ZSET<br>
散列HASH
子主题
列表LIST
列表结构
单节点Node结构
特性
双端,链表节点带有prev和next指针,获取某个节点的前置节点和后置节点的复杂度都是O(1)
无环:表头节点的prev指针和表尾节点的next指针都指向NULL,对链表的访问以NULL为终点
带表头指针和表尾指针:通过list结构的head指针和tail指针,程序获取链表的表头节点和表尾节点的复杂度为O(1)
带链表长度计数器:程序使用list结构的len属性来对list持有的链表节点进行计数,程序获取链表中节点数量的复杂度为O(1)
多态:链表节点使用void*指针来保存节点值,并且可以通过list结构的dup、free、match三个属性为节点值设置类型特定函数,所以链表可以用于保存各种不同类型的值
键值结构
全局哈希表
底层数据结构
事务
非事务流水线
分布式锁<br>
计数信号量
任务队列<br>
先进先出队列<br>
延迟任务
降低内存占用优化<br>
压缩列表<br>
默认配置如上<br>
集合的整数集合编码<br>
分片
收藏
0 条评论
下一页