- 慢查询
- Bitmap
- pipeline
- 发布订阅
- HyperLogLog
- GEO
慢查询
流程:1客户端发送 2redis排队 3执行命令(慢查询阶段) 4返回结果
注:客户端超时不一定慢查询 , 慢查询是客户端超时的一个因素
两个配置:
slowlog-max-len
1先进先出的一个队列
2队列是一个固定长度
3保存在内存当中
slowlog-log-slower-than
1慢查询阈值(单位:微妙)
2slowlog-log-slower-than=0,记录所有的命令
3slowlog-log-slower-than<0,不记录任何命令
配置方法
1、默认值:
config get slowlog-max-len = 128
config get slowlog-log-slower-than = 10000
2、修改配置文件重启 (不推荐)
3、动态配置
config set slowlog-max-len = 128
config set slowlog-log-slower-than = 10000
慢查询的命令
slowlog get [n] 获取几条慢查询队列
slowlog len 获取慢查询队列长度
slowlog reset 清空慢查询队列
pipeline
1次pipeline = 1次网络时间+n次命令操作时间
发布订阅
publish
unsubscribe
subscribe
其他
publish channel message
eg: publish sohu:tv "hello world" //可以查看订阅者个数
subscribe [channel] //一个或者多个
unsubscribe [channel] //一个或者多个
消息队列--------抢 模式
Bitmap -------------- 独立用户统计
setbit key offset value //给位图指定索引设置值
eg: setbit unique:users:2016-04-05 0 1 //偏移量0 数值设为1
getbit key offset
bitcount key [start end]
HyperLogLog
是否能容忍错误
是否需要单条数据?
GEO----------zset实现
geopos key member [member ...] //获取地理位置信息
eg: geopos cities:locations tianjingetdist key member1 member2 [unit]
eg:geodist cities:locations tianjin beijing kmgeoradius //指定范围内member
georadiusbymember key member