PHP + Redis中的实际流水线操作,而不是批处理

There's a lot of information on "pipelining" in PHP+Redis on the web. However, When you actually start looking at the examples, not a single one of them does actual pipelining. All they do is batch processing. As examples, let's take Predis ->pipeline() (https://github.com/nrk/predis) and Phpredis ->multi() (https://github.com/nicolasff/phpredis). They basically suspend execution of commands and instead collect the commands into a buffer, then execute them as a batch when calling ->execute() / ->exec() later.

Disadvantages: - has to allocate a command buffer that can grow large for many commands - needs a round-trip to the server once for every batch of commands

The behaviour I would expect from pipelining mode is: Start sending commands as soon as I pass them to the client, not buffer them. Return before the response for a command has arrived. Allow to send more and more commands while the previous ones are "in flight". Once in a while, collect responses from the client that have arrived, without waiting for responses that have not yet arrived.

The strange thing is that the examples actually pass constants to the client that are called "pipelining", yet they describe the behaviour as batch processing.

Big question: How can you actually put those clients into pipelining mode?

douchuo0730
douchuo0730 只是旁注:python的redis-py实现具有类似的局限性,请参见此处。我在msgpack容器中对redis命令的自定义批处理进行了基准测试,由服务器端Lua脚本执行,该脚本优于redis流水线操作(请参阅post)。因此,它对我来说已成为一个问题。
接近 6 年之前 回复
duanque3125
duanque3125 没有等待发送,但等待响应:php调用将立即返回。但是,在内部,它必须跟踪仍然未完成的内容才能报告错误。
接近 6 年之前 回复
douqin3245
douqin3245 挂起的DB命令队列将位于Redis服务器和/或网络套接字中。客户端的排队命令会再次阻止流水线操作。关于错误,我期望同样的效果,就好像我先等待对错误命令的响应,然后发送更多命令,只是没有时间往返。
接近 6 年之前 回复
doxp30826
doxp30826 您必须保留挂起的db命令队列,并将响应与查询匹配。php中的db调用将立即返回,稍后会传递状态;php可能不得不回滚错误。这是基于事件的编程;而不是像PHP一样,但正是我编写的nodejsbeanstalkd接口的工作原理。
接近 6 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐