Reputation: 9136
Suppose that there is one redis-client which is subscribing to channel c1
and another redis-client publishes "data" to channel c1
.
At this point, does the data published is pending in a redis-server by when the client subscribing to "c1" get the data(by calling pubsub.listen()
or pubsub.get_message()
) or go directly to the client subscribing to the channel c1
through a redis-server?
In other words, When a redis-client call pubsub.getMessage()
or pubsub.listen()
, does redis-client send a request to redis-server to get data or just get data from the local socket buffer?
When I read some documents it is saying that pubsub.get_message()
use select module for a socket internally.
It seems to mean that the data subscribed already is in the client local buffer, not server.
Could you give me any suggestion?
Upvotes: 0
Views: 771
Reputation: 64923
Redis pubsub is fire and forget.
In other words, when a publish
command is sent, the message is received by online subscribers, and who wasn't subscribed/listening for messages when the publish
command was sent, won't never get these messages.
Upvotes: 1
Reputation: 230346
When a client does PUBLISH, this command immediately pushes the message into all sockets that are interested in it. The message is not stored in redis. If a client wasn't subscribed at the time of publishing, he will never see the message.
I'm not familiar with python driver for redis, but judging from the names, I'd guess that listen
sends a SUBSCRIBE
command and get_message
takes a message from the local buffer.
Upvotes: 3