Python and Redis

Find tutorials, examples and technical articles that will help you to develop with Redis and Python.

Getting Started#

The Python community has built many client libraries that you can find here. For your first steps with Python and Redis, this article will show how to use the recommended library: redis-py.

Step 1. Install the Redis library using pip#

pip3 install redis

Step 2. Write your application code#

import redis
redis = redis.Redis(
host= 'localhost',
port= '6379')
redis.set('mykey', 'Hello from Python!')
value = redis.get('mykey')
redis.zadd('vehicles', {'car' : 0})
redis.zadd('vehicles', {'bike' : 0})
vehicles = redis.zrange('vehicles', 0, -1)

Find more information about Redis & Redis connections in the "Redis Connect".

More developer resources#

Sample Code#

Flask Simple Rate limiting Example Application that shows how to do rate limiting using various Redis datastructure.

Technical Articles & Videos#

Beyond the Cache with Python

Redis University#

Redis for Python Developers#

A complete introduction to Redis for Python developers.