Home > Backend Development > PHP Tutorial > redis question?

redis question?

WBOY
Release: 2016-08-04 09:20:31
Original
905 people have browsed it

Redis queue, is a program put in and taken out immediately? Or should one program put it in and another program take it out? ? ? ?

Redis is single-threaded. Is it possible to have two programs put it in and get it at the same time? Is it possible to queue up the two programs so that only one program can get it instantly

Will multiple programs that are operated at the same time be automatically queued?

Reply content:

Redis queue, is a program put in and taken out immediately? Or should one program put it in and another program take it out? ? ? ?

Redis is single-threaded. Is it possible to have two programs put it in and get it at the same time? Is it possible to queue up the two programs so that only one program can get it instantly

Will multiple programs that are operated at the same time be automatically queued?

    The redis server does not care which process pushes or pops, it just processes the queued requests sequentially.
  1. For single-process push and pop, the list is used as a queue or stack.
  2. When used as a message queue, producer push, consumer pop.
  3. If you want to do rpc asynchronous communication, you can open multiple lists, put one req for the processor to receive and process, and then put the resp into the corresponding caller's receiving queue
First of all, in the concept of concurrency, there is no situation where two threads can get data at the same time. It has nothing to do with whether redis is single-threaded or not. It has something to do with how many CPUs you have.

If you are fetching data and processing data with multiple threads, don’t consider the execution issue. The order will definitely be messed up

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template