Skip to content

redis-py

The official Python client library for talking to Redis from Python code.

Stars
13.7k
Forks
2.8k
Licence
MIT
Language
Python
Last update
4 days ago
Type
Library

What it is

redis-py is a Python library that lets Python programs connect to a Redis server and run its commands, such as storing and reading key-value data. Redis is a fast in-memory data store, and this library is the official way to use it from Python. It also supports pipelines to batch commands, Pub/Sub for messages on channels, and cluster and async connections.

  • Store and fetch values with Redis from a Python web app
  • Batch several Redis commands into one round trip using a pipeline
  • Subscribe to Redis Pub/Sub channels to receive messages
  • Connect to a Redis Cluster or use async connections in asyncio code

Great for

  • Python developers who need to read and write data in a Redis server
  • Backend teams building caching or session storage on Redis
  • Projects that want the official Redis-maintained Python client
  • Developers using Redis Cluster or async Python code

Not ideal for

  • People who need a full object-mapping layer; the README points to redis-om-python for that
  • Non-programmers, since it is a code library rather than an app
  • Projects running very old Python versions, because recent releases drop support for older Python versions
Step-by-step guide: how to use redis-pyInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Python (the README notes version support changes by release; check the Note lines) · A running Redis server, for example via Docker

    Install redis-py

    pip install redis

    Install with faster hiredis parser

    pip install "redis[hiredis]"

    Start a Redis server with Docker

    docker run -p 6379:6379 -it redis:latest
  2. 2

    Run it

    • Start a Redis server, for example with the Docker command in the README.
    • Install the library with pip install redis.
    • In Python, import redis and create a client with redis.Redis(host='localhost', port=6379, db=0).
    • Call r.set('foo', 'bar') and r.get('foo') to confirm the round trip.
  3. 3

    Get the most out of it

    • Set decode_responses=True if you want strings instead of bytes.
    • Use pipelines to batch commands and reduce round trips.
    • Use a ConnectionPool to share connections across clients.
    • Install the hiredis extra for a compiled response parser.
    • Set legacy_responses=False in new projects to get unified response shapes, per the RESP3 section.

Downloads

Strengths

  • Official client maintained under the redis organization on GitHub
  • Covers the standard Redis commands with a documented API and a docs site
  • Has an optional hiredis extra for faster response parsing

Trade-offs

  • Responses come back as bytes by default, so you must set decode_responses=True for strings
  • Version support depends on the Redis server version; the README shows a compatibility table to check

How it compares

ProjectStarsTypeLevelUpdatedBest for
redis-py (this)13.7kLibrarybeginner4 days agoPython developers who need to read and write data in a Redis server
ioredis15.4kLibrarybeginner4 days agoNode.js backend developers who already run Redis and want a full-featured client
jedis12.4kLibraryintermediate4 days agoJava developers who need to read and write data in Redis from an application
AnotherRedisDesktopManager34.8kAppbeginner3 months agoDevelopers who prefer a visual interface over redis-cli for inspecting keys
node-redis17.6kLibraryintermediate4 days agoNode.js developers who need to read and write Redis data from an application
codis13.2kDev tooladvanced2.6 years agoTeams running Redis that have outgrown a single server

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.