N
N
nektobit2018-06-19 10:36:18
PHP
nektobit, 2018-06-19 10:36:18

Redis, PHP and SSE - why pub / sub if everything works?

I asked myself a question about live notifications, I took a php lib to work with radishes, I took the client code from here https://www.w3schools.com/html/html5_serversenteve... I start it
- messages from the server come
in. Changed the value of the key in Redis - the new value
1 came. Question: often in this bundle it is advised to use Redis pub/sub. What for? After all, the updated data is arriving ... Explain on your fingers what is the advantage of using pub / sub in conjunction with SSE. Is it possible in php? Can you post a live code example? I tried several libraries from github, but I didn’t understand how to use pub / sub (
2. Another question: I didn’t quite understand what channel is in Redis. I open Redis DM - I see the key and value. I don’t see Channel.
3. And another follow-up question: in order to get data by key for a specific user, I will have to look at the user's session in the database (I plan to tie it to WP), how can I make sure that MySQL is not pulled once again?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fixid, 2018-06-19
@nektobit

Redis actually consists of two parts:
1. key-value store
2. channel
Channel cannot be seen through Redis DM.
The channel appears at the time of pub/sub and exists as long as there is someone pub/sub.
The channel is needed for instant mass mailing. All subs subscribed to the same channel instantly receive a message from pub. Messages are not stored anywhere, whoever has not received it will never receive it again, a kind of UDP message.
In this mode, redis supports as many clients as you can afford concurrent connections to the server. At the same time consuming relatively few resources.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question