图片解析应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
9.0 KiB

  1. Metadata-Version: 2.1
  2. Name: redis
  3. Version: 5.0.8
  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.3 ; python_full_version < "3.11.3"
  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. ## How do I Redis?
  55. [Learn for free at Redis University](https://redis.io/university/)
  56. [Try the Redis Cloud](https://redis.io/try-free/)
  57. [Dive in developer tutorials](https://redis.io/learn)
  58. [Join the Redis community](https://redis.io/community/)
  59. [Work at Redis](https://redis.io/careers/)
  60. ## Installation
  61. Start a redis via docker:
  62. ``` bash
  63. docker run -p 6379:6379 -it redis/redis-stack:latest
  64. ```
  65. To install redis-py, simply:
  66. ``` bash
  67. $ pip install redis
  68. ```
  69. For faster performance, install redis with hiredis support, this provides a compiled response parser, and *for most cases* requires zero code changes.
  70. By default, if hiredis >= 1.0 is available, redis-py will attempt to use it for response parsing.
  71. ``` bash
  72. $ pip install "redis[hiredis]"
  73. ```
  74. Looking for a high-level library to handle object mapping? See [redis-om-python](https://github.com/redis/redis-om-python)!
  75. ## Supported Redis Versions
  76. 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).
  77. The table below highlights version compatibility of the most-recent library versions and redis versions.
  78. | Library version | Supported redis versions |
  79. |-----------------|-------------------|
  80. | 3.5.3 | <= 6.2 Family of releases |
  81. | >= 4.5.0 | Version 5.0 to 7.0 |
  82. | >= 5.0.0 | Version 5.0 to current |
  83. ## Usage
  84. ### Basic Example
  85. ``` python
  86. >>> import redis
  87. >>> r = redis.Redis(host='localhost', port=6379, db=0)
  88. >>> r.set('foo', 'bar')
  89. True
  90. >>> r.get('foo')
  91. b'bar'
  92. ```
  93. 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).
  94. #### RESP3 Support
  95. 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*
  96. ``` python
  97. >>> import redis
  98. >>> r = redis.Redis(host='localhost', port=6379, db=0, protocol=3)
  99. ```
  100. ### Connection Pools
  101. 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).
  102. ``` python
  103. >>> pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
  104. >>> r = redis.Redis(connection_pool=pool)
  105. ```
  106. 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).
  107. ### Redis Commands
  108. 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).
  109. ## Advanced Topics
  110. The [official Redis command documentation](https://redis.io/commands)
  111. does a great job of explaining each command in detail. redis-py attempts
  112. to adhere to the official command syntax. There are a few exceptions:
  113. - **MULTI/EXEC**: These are implemented as part of the Pipeline class.
  114. The pipeline is wrapped with the MULTI and EXEC statements by
  115. default when it is executed, which can be disabled by specifying
  116. transaction=False. See more about Pipelines below.
  117. - **SUBSCRIBE/LISTEN**: Similar to pipelines, PubSub is implemented as
  118. a separate class as it places the underlying connection in a state
  119. where it can\'t execute non-pubsub commands. Calling the pubsub
  120. method from the Redis client will return a PubSub instance where you
  121. can subscribe to channels and listen for messages. You can only call
  122. PUBLISH from the Redis client (see [this comment on issue
  123. #151](https://github.com/redis/redis-py/issues/151#issuecomment-1545015)
  124. for details).
  125. For more details, please see the documentation on [advanced topics page](https://redis.readthedocs.io/en/stable/advanced_features.html).
  126. ### Pipelines
  127. 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.
  128. ``` python
  129. >>> pipe = r.pipeline()
  130. >>> pipe.set('foo', 5)
  131. >>> pipe.set('bar', 18.5)
  132. >>> pipe.set('blee', "hello world!")
  133. >>> pipe.execute()
  134. [True, True, True]
  135. ```
  136. ### PubSub
  137. The following example shows how to utilize [Redis Pub/Sub](https://redis.io/docs/manual/pubsub/) to subscribe to specific channels.
  138. ``` python
  139. >>> r = redis.Redis(...)
  140. >>> p = r.pubsub()
  141. >>> p.subscribe('my-first-channel', 'my-second-channel', ...)
  142. >>> p.get_message()
  143. {'pattern': None, 'type': 'subscribe', 'channel': b'my-second-channel', 'data': 1}
  144. ```
  145. --------------------------
  146. ### Author
  147. redis-py is developed and maintained by [Redis Inc](https://redis.io). It can be found [here](
  148. https://github.com/redis/redis-py), or downloaded from [pypi](https://pypi.org/project/redis/).
  149. Special thanks to:
  150. - Andy McCurdy (<sedrik@gmail.com>) the original author of redis-py.
  151. - Ludovico Magnocavallo, author of the original Python Redis client,
  152. from which some of the socket code is still used.
  153. - Alexander Solovyov for ideas on the generic response callback
  154. system.
  155. - Paul Hubbard for initial packaging support.
  156. [![Redis](./docs/_static/logo-redis.svg)](https://redis.io)