Python client for Valkey forked from redis-py
Actively maintained. Last release 7 weeks ago, commits in 15 of the last 26 weeks. A safe choice.
pip install valkeyvalkey-py
The Python interface to the Valkey key-value store.
Installation | Usage | Documentation | Advanced Topics | Contributing
Installation
Start a valkey via docker:
docker run -p 6379:6379 -it valkey/valkey:latest
To install valkey-py, simply:
$ pip install valkey
For faster performance, install valkey with libvalkey support, this provides a compiled response parser, and for most cases requires zero code changes. By default, if libvalkey >= 2.3.2 is available, valkey-py will attempt to use it for response parsing.
$ pip install "valkey[libvalkey]"
Usage
Basic Example
import valkey
r = valkey.Valkey(host='localhost', port=6379, db=0)
r.set('foo', 'bar')
# True
r.get('foo')
# b'bar'
The above code connects to localhost on port 6379, sets a value in Redis, and retrieves it. All responses are returned as bytes in Python, to receive decoded strings, set . For this, and more connection options, see .
