Redis ( host = 'localhost', port = 6379, db = 0, protocol = 3 ) Connection Poolsīy default, redis-py uses a connection pool to manage connections. To enable support for RESP3, ensure you have at least version 5.0 of the client, and change your connection object to include protocol=3 > import redis > r = redis. For this, and more connection options, see these examples. All responses are returned as bytes in Python, to receive decoded strings, set decode_responses=True. The above code connects to localhost on port 6379, sets a value in Redis, and retrieves it. Redis ( host = 'localhost', port = 6379, db = 0 ) > r. Usage Basic Example > import redis > r = redis. The table below highlights version compatibility of the most-recent library versions and redis versions. The most recent version of this library supports redis version 5.0, 6.0, 6.2, 7.0 and 7.2. Looking for a high-level library to handle object mapping? See redis-om-python! Supported Redis Versions To install redis-py, simply: $ pip install redisįor faster performance, install redis with hiredis support, this provides a compiled response parser, and for most cases requires zero code changes.īy default, if hiredis >= 1.0 is available, redis-py will attempt to use it for response parsing. Start a redis via docker: docker run -p 6379:6379 -it redis/redis-stack:latest **Note: ** redis-py 5.0 will be the last version of redis-py to support Python 3.7, as it has reached end of life. Installation | Usage | Advanced Topics | Contributing The Python interface to the Redis key-value store.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |