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')
print(value)
redis.zadd('vehicles', {'car' : 0})
redis.zadd('vehicles', {'bike' : 0})
vehicles = redis.zrange('vehicles', 0, -1)
print(vehicles)

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 Marketplace#

Redis Marketplace is like an “App Store” for Redis sample apps. You can easily find apps for your preferred frameworks and languages. Below are few of these apps. Click here to access the complete lists of apps

Rate-Limiting app in Python & Django#

marketplace

Rate Limiting app built in Python & Django

Leaderboard app in Python & Django#

marketplace

How to implement leaderboard app in Python & Django

Redis University#

Redis for Python Developers#

A complete introduction to Redis for Python developers.