Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7587547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:42:03+00:00 2026-05-30T19:42:03+00:00

Somebody asked me what PubSub was and how to create a channel (in comment

  • 0

Somebody asked me what PubSub was and how to create a channel (in comment from my answer) and I pointed him to the article on redis.io => http://redis.io/topics/pubsub. I think it is pretty clear, but I am wondering if somebody has a better explanation. Ideally, describe it clearly using redis-cli.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:42:04+00:00Added an answer on May 30, 2026 at 7:42 pm

    Publish/subscribe is a pretty simple paradigm. Think of it like you’re running a talk show on a radio station. That’s PUBLISH. You’re hoping at least one or more people will pick up your channel to listen to your messages on the radio show (SUBSCRIBE) and maybe even do some stuff, but you’re not talking to folks directly.

    Let’s have some fun with redis-cli!

    redis 127.0.0.1:6379> PUBLISH myradioshow "Good morning everyone!"
    (integer) 0
    redis 127.0.0.1:6379> PUBLISH myradioshow "How ya'll doin tonight?"
    (integer) 0
    redis 127.0.0.1:6379> PUBLISH myradioshow "Hello? Is anyone listening? I'm not wearing pants."
    (integer) 0
    

    Notice there are no clients receiving the messages on your “myradioshow” channel (that’s the 0 in the response). Nobody is listening. Now, open another redis-cli (or for more fun times have a friend open up their redis-cli and connect to your server) and SUBSCRIBE to the channel:

    redis 127.0.0.1:6379> SUBSCRIBE myradioshow
    Reading messages... (press Ctrl-C to quit)
    1) "subscribe"
    2) "myradioshow"
    3) (integer) 1
    

    Go back to your original redis-cli and continue your show:

    redis 127.0.0.1:6379> PUBLISH myradioshow "Next caller gets a free loaf of bread!"
    (integer) 1
    

    Notice that “1” at the end? You have a listener! Like magic, in your SUBSCRIBE-d terminal:

    1) "message"
    2) "myradioshow"
    3) "Next caller gets a free loaf of bread!"
    

    Of course, in reality, you’re probably going to want to do stuff that’s more useful than telling your clients about your pants-less lifestyle, such as firing events on your server or running some kind of tasks/jobs. Maybe not though! 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Somebody asked a question about how to create a web service (as opposed to
Somebody asked similar question not long ago. But nobody answered comprehensively. Assume I have:
There is one aspect of TDD which I never fully understood. Suppose somebody asked
I initially asked this on Superuser, but somebody advised me to repost here. I
Good afternoon, Somebody asked me a question today and neither did I know the
Somebody has asked me to make an app in php that will generate a
I have looked around here to see if somebody has asked this question before
Previously I asked which DHT implementations are compatible with Python 3.x - StackOverflow's answer
I think this has been asked before but even though I searched Google I
Somebody asked me: can an array in java contain integers and floats? She got

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.