Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

redis优化

  • Redis可以支撑每秒数万的读写,但这是指服务端的处理能力,对客户端来说,一条命令还会消耗网络往返时间,所以要尽量把多条命令合并起来发送,或者用mget或mset等批量指令

  • 很多存储系统和编程语言内部使用CAS机制实现原子性的自增计数,会有一定的CPU开销,而Redis完全不需要,因为它是单线程的,任何命令都要顺序执行