Published a message to a particular channel.
redis 127.0.0.1:6379> PUBLISH channel message
(integer) 0
Using another Redis client I subscribed the channel .
redis 127.0.0.1:6379> SUBSCRIBE channel
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "channel"
3) (integer) 1
In the Redis client I got all the Published messages. Now I want to unsubscribe from the subscribed channel. But I cant type unsubscribe in the Redis client. When I use Ctrl+c full Redis client quits. How to write the Unsubscribe command in Redis Client?
I dont think you can issue unsubscribe in the client cause the client was blocked. I wrote a ruby script to show how to use unsubscribe.
If you remove r.unsubscribe, the script will be blocked. And you can add if clause to check when to unsubscribe client.ex: