Redis的数据结构和内部编码

image.png
image.png
redis是单线程,一次只执行一条命令,那为何能够这么快:redis

  1. 纯内存
  2. 非阻塞IO
  3. 避免线程切换和竞态消耗

在使用过程当中要注意:spa

  1. 一次只运行一条命令
  2. 避免长(慢)命令,例如keys、flushall、flushdb、slow sua script、multi/exec、operate big value(collection)
  3. redis在 fsync file descriptior、close file descriptor时会有独立的线程来执行
相关文章
相关标签/搜索