Skip to content

Kalbaliev/Python-Redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Redis on Python

First of All, for using Redis on Python we have to up Redis Server on Docker

Redis up on Docker

Pull Redis image from DockerHub

docker pull redis

Up Redis Server on 6379 port

docker run --name redis-server -p 6379:6379 redis

Already everything is okay on Docker side!

Let's begin Python coding :)

Python

  pip install redis

Connect to Redis Server on Python

r = redis.Redis(host='localhost', port=6379, db=0)

Pub-Sub (Messaging Broker on Redis) with pub-sub.py file

Subscribe to channel (channels) on CMD terminal

  • subscribeChannel (channels) - give channels' names from list type
  python pub-sub.py subscribeChannel ['first-channel','second-channel']

Publish message to channel on CMD terminal

  • publishChannel (channel,msg) - give channel's' name and message from string (with "(2 quotes) symbol, not '(1 quote) symbol)
  python pub-sub.py publishChannel "first-channel" "My first message from Redis"

About

How to Use Redis on Python Programming Language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published