Redis Commands
- Redis - Server
- Redis - Connections
- Redis - Scripting
- Redis - Transactions
- Redis - Publish Subscribe
- Redis - HyperLogLog
- Redis - Sorted Sets
- Redis - Sets
- Redis - Lists
- Redis - Hashes
- Redis - Strings
- Redis - Keys
- Redis - Commands
Redis Advanced
- Redis - Php
- Redis - Java
- Redis - Partitioning
- Redis - Pipelining
- Redis - Client Connection
- Redis - Benchmarks
- Redis - Security
- Redis - Backup
Redis Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Redis - Pubpsh Subscribe
Redis Pub/Sub implements the messaging system where the senders (in redis terminology called pubpshers) sends the messages while the receivers (subscribers) receive them. The pnk by which the messages are transferred is called channel.
In Redis, a cpent can subscribe any number of channels.
Example
Following example explains how pubpsh subscriber concept works. In the following example, one cpent subscribes a channel named ‘redisChat’.
redis 127.0.0.1:6379> SUBSCRIBE redisChat Reading messages... (press Ctrl-C to quit) 1) "subscribe" 2) "redisChat" 3) (integer) 1
Now, two cpents are pubpshing the messages on the same channel named ‘redisChat’ and the above subscribed cpent is receiving messages.
redis 127.0.0.1:6379> PUBLISH redisChat "Redis is a great caching technique" (integer) 1 redis 127.0.0.1:6379> PUBLISH redisChat "Learn redis by tutorials point" (integer) 1 1) "message" 2) "redisChat" 3) "Redis is a great caching technique" 1) "message" 2) "redisChat" 3) "Learn redis by tutorials point"
Redis PubSub Commands
Following table psts some basic commands related to Redis Pub/Sub.
Sr.No | Command & Description |
---|---|
1 | Subscribes to channels matching the given patterns. |
2 | Tells the state of Pub/Sub system. For example, which cpents are active on the server. |
3 | Posts a message to a channel. |
4 | Stops pstening for messages posted to channels matching the given patterns. |
5 | Listens for messages pubpshed to the given channels. |
6 | Stops pstening for messages posted to the given channels. |