METADATA 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. Metadata-Version: 2.1
  2. Name: redis
  3. Version: 5.0.1
  4. Summary: Python client for Redis database and key-value store
  5. Home-page: https://github.com/redis/redis-py
  6. Author: Redis Inc.
  7. Author-email: oss@redis.com
  8. License: MIT
  9. Project-URL: Documentation, https://redis.readthedocs.io/en/latest/
  10. Project-URL: Changes, https://github.com/redis/redis-py/releases
  11. Project-URL: Code, https://github.com/redis/redis-py
  12. Project-URL: Issue tracker, https://github.com/redis/redis-py/issues
  13. Keywords: Redis,key-value store,database
  14. Platform: UNKNOWN
  15. Classifier: Development Status :: 5 - Production/Stable
  16. Classifier: Environment :: Console
  17. Classifier: Intended Audience :: Developers
  18. Classifier: License :: OSI Approved :: MIT License
  19. Classifier: Operating System :: OS Independent
  20. Classifier: Programming Language :: Python
  21. Classifier: Programming Language :: Python :: 3
  22. Classifier: Programming Language :: Python :: 3 :: Only
  23. Classifier: Programming Language :: Python :: 3.7
  24. Classifier: Programming Language :: Python :: 3.8
  25. Classifier: Programming Language :: Python :: 3.9
  26. Classifier: Programming Language :: Python :: 3.10
  27. Classifier: Programming Language :: Python :: 3.11
  28. Classifier: Programming Language :: Python :: Implementation :: CPython
  29. Classifier: Programming Language :: Python :: Implementation :: PyPy
  30. Requires-Python: >=3.7
  31. Description-Content-Type: text/markdown
  32. License-File: LICENSE
  33. Requires-Dist: async-timeout >=4.0.2 ; python_full_version <= "3.11.2"
  34. Requires-Dist: importlib-metadata >=1.0 ; python_version < "3.8"
  35. Requires-Dist: typing-extensions ; python_version < "3.8"
  36. Provides-Extra: hiredis
  37. Requires-Dist: hiredis >=1.0.0 ; extra == 'hiredis'
  38. Provides-Extra: ocsp
  39. Requires-Dist: cryptography >=36.0.1 ; extra == 'ocsp'
  40. Requires-Dist: pyopenssl ==20.0.1 ; extra == 'ocsp'
  41. Requires-Dist: requests >=2.26.0 ; extra == 'ocsp'
  42. # redis-py
  43. The Python interface to the Redis key-value store.
  44. [![CI](https://github.com/redis/redis-py/workflows/CI/badge.svg?branch=master)](https://github.com/redis/redis-py/actions?query=workflow%3ACI+branch%3Amaster)
  45. [![docs](https://readthedocs.org/projects/redis/badge/?version=stable&style=flat)](https://redis-py.readthedocs.io/en/stable/)
  46. [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
  47. [![pypi](https://badge.fury.io/py/redis.svg)](https://pypi.org/project/redis/)
  48. [![pre-release](https://img.shields.io/github/v/release/redis/redis-py?include_prereleases&label=latest-prerelease)](https://github.com/redis/redis-py/releases)
  49. [![codecov](https://codecov.io/gh/redis/redis-py/branch/master/graph/badge.svg?token=yenl5fzxxr)](https://codecov.io/gh/redis/redis-py)
  50. [Installation](#installation) | [Usage](#usage) | [Advanced Topics](#advanced-topics) | [Contributing](https://github.com/redis/redis-py/blob/master/CONTRIBUTING.md)
  51. ---------------------------------------------
  52. **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](https://devguide.python.org/versions/). redis-py 5.1 will support Python 3.8+.
  53. ---------------------------------------------
  54. ## Installation
  55. Start a redis via docker:
  56. ``` bash
  57. docker run -p 6379:6379 -it redis/redis-stack:latest
  58. ```
  59. To install redis-py, simply:
  60. ``` bash
  61. $ pip install redis
  62. ```
  63. For faster performance, install redis with hiredis support, this provides a compiled response parser, and *for most cases* requires zero code changes.
  64. By default, if hiredis >= 1.0 is available, redis-py will attempt to use it for response parsing.
  65. ``` bash
  66. $ pip install "redis[hiredis]"
  67. ```
  68. Looking for a high-level library to handle object mapping? See [redis-om-python](https://github.com/redis/redis-om-python)!
  69. ## Supported Redis Versions
  70. The most recent version of this library supports redis version [5.0](https://github.com/redis/redis/blob/5.0/00-RELEASENOTES), [6.0](https://github.com/redis/redis/blob/6.0/00-RELEASENOTES), [6.2](https://github.com/redis/redis/blob/6.2/00-RELEASENOTES), [7.0](https://github.com/redis/redis/blob/7.0/00-RELEASENOTES) and [7.2](https://github.com/redis/redis/blob/7.2/00-RELEASENOTES).
  71. The table below highlights version compatibility of the most-recent library versions and redis versions.
  72. | Library version | Supported redis versions |
  73. |-----------------|-------------------|
  74. | 3.5.3 | <= 6.2 Family of releases |
  75. | >= 4.5.0 | Version 5.0 to 7.0 |
  76. | >= 5.0.0 | Version 5.0 to current |
  77. ## Usage
  78. ### Basic Example
  79. ``` python
  80. >>> import redis
  81. >>> r = redis.Redis(host='localhost', port=6379, db=0)
  82. >>> r.set('foo', 'bar')
  83. True
  84. >>> r.get('foo')
  85. b'bar'
  86. ```
  87. 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 *decode_responses=True*. For this, and more connection options, see [these examples](https://redis.readthedocs.io/en/stable/examples.html).
  88. #### RESP3 Support
  89. 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*
  90. ``` python
  91. >>> import redis
  92. >>> r = redis.Redis(host='localhost', port=6379, db=0, protocol=3)
  93. ```
  94. ### Connection Pools
  95. By default, redis-py uses a connection pool to manage connections. Each instance of a Redis class receives its own connection pool. You can however define your own [redis.ConnectionPool](https://redis.readthedocs.io/en/stable/connections.html#connection-pools).
  96. ``` python
  97. >>> pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
  98. >>> r = redis.Redis(connection_pool=pool)
  99. ```
  100. Alternatively, you might want to look at [Async connections](https://redis.readthedocs.io/en/stable/examples/asyncio_examples.html), or [Cluster connections](https://redis.readthedocs.io/en/stable/connections.html#cluster-client), or even [Async Cluster connections](https://redis.readthedocs.io/en/stable/connections.html#async-cluster-client).
  101. ### Redis Commands
  102. There is built-in support for all of the [out-of-the-box Redis commands](https://redis.io/commands). They are exposed using the raw Redis command names (`HSET`, `HGETALL`, etc.) except where a word (i.e. del) is reserved by the language. The complete set of commands can be found [here](https://github.com/redis/redis-py/tree/master/redis/commands), or [the documentation](https://redis.readthedocs.io/en/stable/commands.html).
  103. ## Advanced Topics
  104. The [official Redis command documentation](https://redis.io/commands)
  105. does a great job of explaining each command in detail. redis-py attempts
  106. to adhere to the official command syntax. There are a few exceptions:
  107. - **MULTI/EXEC**: These are implemented as part of the Pipeline class.
  108. The pipeline is wrapped with the MULTI and EXEC statements by
  109. default when it is executed, which can be disabled by specifying
  110. transaction=False. See more about Pipelines below.
  111. - **SUBSCRIBE/LISTEN**: Similar to pipelines, PubSub is implemented as
  112. a separate class as it places the underlying connection in a state
  113. where it can\'t execute non-pubsub commands. Calling the pubsub
  114. method from the Redis client will return a PubSub instance where you
  115. can subscribe to channels and listen for messages. You can only call
  116. PUBLISH from the Redis client (see [this comment on issue
  117. #151](https://github.com/redis/redis-py/issues/151#issuecomment-1545015)
  118. for details).
  119. For more details, please see the documentation on [advanced topics page](https://redis.readthedocs.io/en/stable/advanced_features.html).
  120. ### Pipelines
  121. The following is a basic example of a [Redis pipeline](https://redis.io/docs/manual/pipelining/), a method to optimize round-trip calls, by batching Redis commands, and receiving their results as a list.
  122. ``` python
  123. >>> pipe = r.pipeline()
  124. >>> pipe.set('foo', 5)
  125. >>> pipe.set('bar', 18.5)
  126. >>> pipe.set('blee', "hello world!")
  127. >>> pipe.execute()
  128. [True, True, True]
  129. ```
  130. ### PubSub
  131. The following example shows how to utilize [Redis Pub/Sub](https://redis.io/docs/manual/pubsub/) to subscribe to specific channels.
  132. ``` python
  133. >>> r = redis.Redis(...)
  134. >>> p = r.pubsub()
  135. >>> p.subscribe('my-first-channel', 'my-second-channel', ...)
  136. >>> p.get_message()
  137. {'pattern': None, 'type': 'subscribe', 'channel': b'my-second-channel', 'data': 1}
  138. ```
  139. --------------------------
  140. ### Author
  141. redis-py is developed and maintained by [Redis Inc](https://redis.com). It can be found [here](
  142. https://github.com/redis/redis-py), or downloaded from [pypi](https://pypi.org/project/redis/).
  143. Special thanks to:
  144. - Andy McCurdy (<sedrik@gmail.com>) the original author of redis-py.
  145. - Ludovico Magnocavallo, author of the original Python Redis client,
  146. from which some of the socket code is still used.
  147. - Alexander Solovyov for ideas on the generic response callback
  148. system.
  149. - Paul Hubbard for initial packaging support.
  150. [![Redis](./docs/logo-redis.png)](https://www.redis.com)