多进程 - 多个进程去读取redis消息队列是否会发生冲突?
PHP中文网
PHP中文网 2017-04-27 09:03:23
0
3
974

问题

我创建多个进程去同时读取redis做的消息队列 请问这个会发生读取冲突么? 原因是什么呢?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
黄舟

No conflicts, each element in the queue will only be read once.

曾经蜡笔没有小新

No problem just reading. . .

Peter_Zhu

Redis itself guarantees mutual exclusion of queue reading and writing. Redis is single-threaded and works roughly like this. Your multi-process reading can actually send multiple read request packets in parallel. These request packets arrive in the socket buffer of redis. The processing of redis is to respond to your request serially without locks. If redis is changed to multi-threading one day, you can also lock the mutex to ensure that nothing happens when reading the queue.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!