Working with Redis in Python

I.What is Redis:
Redis is a NoSQL databases that is extremely fast, support caching and store value in different format.
Sometimes, if your data is uncategorized or you want to get it fast, you should think of Redis.


Please go to Redis-official site for download and install Redis in your local environment.

After that, to check if it’s working.


You should see the following like:

Image for post
Image for post

After that, to access to the local running server via command line, you can use

Image for post
Image for post

III.Work with remote redis via command line:
For example you need to work with the redis-cluster remote (Check out what is redis-cluster, you would need to know what is the domain name, what is the password for authen.

1.Connect The command would be like

redis-cli -h host_name -a pass_word -c

-h for the hostname

-a is for the password

  • c is for automatically redirect if the node is moved.

2.Common command: keys * : to get all the key info: to get information about redis-cluster get: to get the value of key

IV.Sample project for working with Redis:

I write some sample code for working with Redis-cluster using redis-cluster-python.

def test_masters_slaves():
from rediscluster import RedisCluster
nodes = [{"host": f"hostname",
"port": "6379"}]
r = RedisCluster(startup_nodes=nodes, password="xxxxx", skip_full_coverage_check=True, decode_responses=u'utf-8')
all_keys = r.keys("*")
print(f"\nKeys are : {all_keys}")

You can checkout the source code in here.

Hope this helps!

Notes: If you feel this blog help you and want to show the appreciation, feel free to drop by :

Image for post
Image for post

This will help me to contributing more valued contents.

Originally published at on December 25, 2019.

Written by

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store