Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Publish & Subscribe for dummies:

Open 2 different windows (pane) in terminal and go to redis console:
redis-cli

Now to subscribe into a specific channel:
127.0.0.1:6379> SUBSCRIBE first second
Reading messages... (press Ctrl-C to quit)
1) "subscribe"
2) "first"
3) (integer) 1
1) "subscribe"
2) "second"
3) (integer) 2

As you can see we have subscribed to 2 channels called first and second. In another window open redis console again by redis-cli command and try to publish to those channels:
PUBLISH second Hello

Now you should see the output below in the first window where you have subscribed to channels:
1) "message"
2) "second"
3) "Hello"

If you want to know more about pub-sub scenario:
https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern

#redis #pub_sub #publish #subscribe #redis_cli
Did you know that you can monitor redis commands live from within redis-cli console?

Go to redis client by typing redis-cli in terminal and then type monitor command and enter:

127.0.0.1:6379> monitor
OK
1514301845.678553 [0 127.0.0.1:59388] "COMMAND"
1514301859.676761 [0 127.0.0.1:59388] "HSET" "user" "name" "ali"

It will log everything that happens on your redis server.

#redis #redis_cli #cli #monitor