redis之pipeline
redis之pipeline
When we have to send multiple commands, we can pack them together in one request and save connection overhead by using pipelines, it is essentially a network optimization. As long as the operations are mutually independent, we can take advantage of this technique:
Redis 是基于client-server的请求响应模型,一条命令的执行:
- 发送命令
- 命令排队
- 命令执行
- 接收返回结果
RTT - round trip time, 如果发送N次命令,等待上一条命令应答后再执行,这中间不仅仅多了RTT(Round Time Trip),而且还频繁的调用系统IO,发送网络请求。
pipeline只要是提升执行效率,减少网络IO。
jedis pipeline support
public void mdel(List<String> keys){ |
notes: redis 提供批量操作命令 mge,mset,同样实现缩减rtt的目的。