Redis
基础
- aof和rdb优点,区别
 - 慢日志查询
 - 缓存一致性,如何避免脏数据
 - 缓存雪崩、缓存穿透
 - 数据淘汰机制
 - 底层网络模型(Linux,Windows,MacOS)
 
分布式锁
ex表示expire,nx表示if not exist
1 |  | 
限流
使用zset+滑动窗口
比如每1分钟限制访问1000次,那么period=60, max_count=1000
zadd rate_limit_key now_ts now_ts(now_ts为当前的时间戳)zremrangebyscore rate_limit_key, 0, now_ts - period * 1000(移除时间窗口之前的行为记录,剩下的都是时间窗口内的)zcard rate_limit_key获取窗口内的行为数量expire rate_limit_key period + 1
判断步骤3中的获取的数量是否小于max_count
big key
- 大key会带来操作时间的上升 即使是
O(logn)的操作,n越大,执行时间越长,Redis单线程处理,会block其他命令执行 - 大key迁移会很麻烦
 - io的开销(将big key传输到client, io会很慢)