| single |
# redis-py
The Python interface to the Redis key-value store.
[CI]
[docs]
[MIT licensed]
[pypi]
[![pre-release]](https://github.com/redis/redis-py/releases)
[codecov]
[Installation] | [Usage] | [Advanced Topics] | [Contributing]
---------------------------------------------
## How do I Redis?
[Learn for free at Redis University]
[Try the Redis Cloud]
[Dive in developer tutorials]
[Join the Redis community]
[Work at Redis]
## Installation
Start a redis via docker (for Redis versions >= 8.0):
``` bash
docker run -p 6379:6379 -it redis:latest
```
Start a redis via docker (for Redis versions < 8.0):
``` bash
docker run -p 6379:6379 -it redis/redis-stack:latest
```
To install redis-py, simply:
``` bash
$ pip install redis
```
For faster performance, install redis with hiredis support, this provides a
compiled response parser, and *for most cases* requires zero code changes.
By default, if hiredis >= 1.0 is available, redis-py will attempt to use it
for response parsing.
``` bash
$ pip install "redis[hiredis]"
```
Looking for a high-level library to handle object mapping? See
[redis-om-python]!
## Supported Redis Versions
The most recent version of this library supports Redis 7.2 and every later
release, up to the latest stable Redis version. CI tests each of these
Redis
release lines.
The table below highlights version compatibility of the most-recent library
versions and redis versions.
| Library version | Supported redis versions |
|-----------------|-------------------|
| 3.5.3 | <= 6.2 Family of releases |
| >= 4.5.0 | Version 5.0 to 7.0 |
| >= 5.0.0 | Version 5.0 to 7.4 |
| >= 6.0.0 | Version 7.2 to current |
### Supported Python Versions
redis-py supports every CPython version that has not reached
[end of life], and PyPy.
`requires-python` in `pyproject.toml` states the minimum Python version for
each
release. If you are on an older Python version, use the last redis-py
release
that supports it:
| Python version | Last supporting redis-py releases |
|----------------|-----------------------------------|
| 3.7 | 5.0.x |
| 3.8 | 6.1.x |
| 3.9 | 7.0.x |
| 3.10 | 8.1.x |
## Usage
### Basic Example
``` python
>>> import redis
>>> r = redis.Redis(host='localhost', port=6379, db=0)
>>> r.set('foo', 'bar')
|