diff options
author | Chayim <chayim@users.noreply.github.com> | 2021-12-30 12:52:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-30 12:52:11 +0200 |
commit | bc3dbb45d7236f96d614c33684a94f3e0fd9ac4a (patch) | |
tree | 5da61d39c34e3ad558be7c78c9f54c185084968e | |
parent | deaaa536568e50b6ce958de0dd6306392e98f13e (diff) | |
download | redis-py-bc3dbb45d7236f96d614c33684a94f3e0fd9ac4a.tar.gz |
Documentation cleanup (#1841)
-rw-r--r-- | docs/commands.rst | 30 | ||||
-rw-r--r-- | docs/connections.rst | 35 | ||||
-rw-r--r-- | docs/index.rst | 4 | ||||
-rw-r--r-- | docs/redis_cluster_commands.rst | 7 | ||||
-rw-r--r-- | docs/redis_commands.rst | 14 | ||||
-rw-r--r-- | docs/redismodules.rst | 115 | ||||
-rw-r--r-- | docs/sentinel_commands.rst | 20 | ||||
-rwxr-xr-x | redis/client.py | 1 | ||||
-rw-r--r-- | redis/cluster.py | 1 | ||||
-rw-r--r-- | redis/commands/graph/commands.py | 2 | ||||
-rw-r--r-- | redis/commands/search/commands.py | 46 | ||||
-rwxr-xr-x | redis/connection.py | 5 | ||||
-rw-r--r-- | redis/sentinel.py | 2 |
13 files changed, 149 insertions, 133 deletions
diff --git a/docs/commands.rst b/docs/commands.rst new file mode 100644 index 0000000..d35f290 --- /dev/null +++ b/docs/commands.rst @@ -0,0 +1,30 @@ +Redis Commands +############## + +Core Commands +************* + +The following functions can be used to replicate their equivalent `Redis command <https://redis.io/commands>`_. Generally they can be used as functions on your redis connection. For the simplest example, see below: + +Getting and settings data in redis:: + + import redis + r = redis.Redis(decode_responses=True) + r.set('mykey', 'thevalueofmykey') + r.get('mykey') + +.. autoclass:: redis.commands.core.CoreCommands + :inherited-members: + +Sentinel Commands +***************** +.. autoclass:: redis.commands.sentinel.SentinelCommands + :inherited-members: + +Redis Cluster Commands +********************** + +The following `Redis commands <https://redis.io/commands>`_ are available within a `Redis Cluster <https://redis.io/topics/cluster-tutorial>`_. Generally they can be used as functions on your redis connection. + +.. autoclass:: redis.commands.cluster.RedisClusterCommands + :inherited-members: diff --git a/docs/connections.rst b/docs/connections.rst index 973821b..cf4657b 100644 --- a/docs/connections.rst +++ b/docs/connections.rst @@ -3,10 +3,41 @@ Connecting to Redis Generic Client ************** -.. autoclass:: redis.client.Redis + +This is the client used to connect directly to a standard redis node. + +.. autoclass:: redis.Redis + :members: + +Sentinel Client +*************** + +Redis `Sentinel <https://redis.io/topics/sentinel>`_ provides high availability for Redis. There are commands that can only be executed against a redis node running in sentinel mode. Connecting to those nodes, and executing commands against them requires a Sentinel connection. + +Connection example (assumes redis redis on the ports listed below): + + >>> from redis import Sentinel + >>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1) + >>> sentinel.discover_master('mymaster') + ('127.0.0.1', 6379) + >>> sentinel.discover_slaves('mymaster') + [('127.0.0.1', 6380)] + +.. autoclass:: redis.sentinel.Sentinel + :members: + +.. autoclass:: redis.sentinel.SentinelConnectionPool + :members: + +Cluster Client +************** + +This client is used for connecting to a redis cluser. + +.. autoclass:: redis.cluster.RedisCluster :members: Connection Pools ***************** .. autoclass:: redis.connection.ConnectionPool - :members:
\ No newline at end of file + :members: diff --git a/docs/index.rst b/docs/index.rst index cbf5115..51b38a2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -56,9 +56,7 @@ Redis Command Functions .. toctree:: :maxdepth: 2 - redis_commands - redis_cluster_commands - sentinel_commands + commands redismodules Module Documentation diff --git a/docs/redis_cluster_commands.rst b/docs/redis_cluster_commands.rst deleted file mode 100644 index de520de..0000000 --- a/docs/redis_cluster_commands.rst +++ /dev/null @@ -1,7 +0,0 @@ -Redis Cluster Commands -###################### - -The following `Redis commands <https://redis.io/commands>`_ are available within a `Redis Cluster <https://redis.io/topics/cluster-tutorial>`_. Generally they can be used as functions on your redis connection. - -.. autoclass:: redis.commands.cluster.RedisClusterCommands - :inherited-members: diff --git a/docs/redis_commands.rst b/docs/redis_commands.rst deleted file mode 100644 index efb76e7..0000000 --- a/docs/redis_commands.rst +++ /dev/null @@ -1,14 +0,0 @@ -Redis Commands -############### - -The following functions can be used to replicate their equivalent `Redis command <https://redis.io/commands>`_. Generally they can be used as functions on your redis connection. For the simplest example, see below: - -Getting and settings data in redis:: - - import redis - r = redis.Redis(decode_responses=True) - r.set('mykey', 'thevalueofmykey') - r.get('mykey') - -.. autoclass:: redis.commands.core.CoreCommands - :inherited-members: diff --git a/docs/redismodules.rst b/docs/redismodules.rst index 53a5008..f311675 100644 --- a/docs/redismodules.rst +++ b/docs/redismodules.rst @@ -3,63 +3,49 @@ Redis Modules Commands Accessing redis module commands requires the installation of the supported `Redis module <https://docs.redis.com/latest/modules/>`_. For a quick start with redis modules, try the `Redismod docker <https://hub.docker.com/r/redislabs/redismod>`_. -RedisTimeSeries Commands -************************ -These are the commands for interacting with the `RedisTimeSeries module <https://redistimeseries.io>`_. Below is a brief example, as well as documentation on the commands themselves. +RedisBloom Commands +******************* +These are the commands for interacting with the `RedisBloom module <https://redisbloom.io>`_. Below is a brief example, as well as documentation on the commands themselves. -**Create a timeseries object with 5 second retention** +**Create and add to a bloom filter** .. code-block:: python import redis - r = redis.Redis() - r.timeseries().create(2, retension_msecs=5) - -.. automodule:: redis.commands.timeseries.commands - :members: TimeSeriesCommands - ------ - -RedisJSON Commands -****************** - -These are the commands for interacting with the `RedisJSON module <https://redisjson.io>`_. Below is a brief example, as well as documentation on the commands themselves. + filter = redis.bf().create("bloom", 0.01, 1000) + filter.add("bloom", "foo") -**Create a json object** +**Create and add to a cuckoo filter** .. code-block:: python import redis - r = redis.Redis() - r.json().set("mykey", ".", {"hello": "world", "i am": ["a", "json", "object!"]} - - -.. automodule:: redis.commands.json.commands - :members: JSONCommands + filter = redis.cf().create("cuckoo", 1000) + filter.add("cuckoo", "filter") ------ +**Create Count-Min Sketch and get information** -RediSearch Commands -******************* +.. code-block:: python -These are the commands for interacting with the `RediSearch module <https://redisearch.io>`_. Below is a brief example, as well as documentation on the commands themselves. + import redis + r = redis.cms().initbydim("dim", 1000, 5) + r.cms().incrby("dim", ["foo"], [5]) + r.cms().info("dim") -**Create a search index, and display its information** +**Create a topk list, and access the results** .. code-block:: python import redis - r = redis.Redis() - r.ft().create_index(TextField("play", weight=5.0), TextField("ball")) - print(r.ft().info()) - + r = redis.topk().reserve("mytopk", 3, 50, 4, 0.9) + info = r.topk().info("mytopk) -.. automodule:: redis.commands.search.commands - :members: SearchCommands +.. automodule:: redis.commands.bf.commands + :members: BFCommands, CFCommands, CMSCommands, TOPKCommands ------ +------ RedisGraph Commands ******************* @@ -92,45 +78,62 @@ These are the commands for interacting with the `RedisGraph module <https://redi .. automodule:: redis.commands.graph.commands :members: GraphCommands ------ +------ -RedisBloom Commands -******************* +RedisJSON Commands +****************** -These are the commands for interacting with the `RedisBloom module <https://redisbloom.io>`_. Below is a brief example, as well as documentation on the commands themselves. +These are the commands for interacting with the `RedisJSON module <https://redisjson.io>`_. Below is a brief example, as well as documentation on the commands themselves. -**Create and add to a bloom filter** +**Create a json object** .. code-block:: python import redis - filter = redis.bf().create("bloom", 0.01, 1000) - filter.add("bloom", "foo") + r = redis.Redis() + r.json().set("mykey", ".", {"hello": "world", "i am": ["a", "json", "object!"]} -**Create and add to a cuckoo filter** -.. code-block:: python +.. automodule:: redis.commands.json.commands + :members: JSONCommands - import redis - filter = redis.cf().create("cuckoo", 1000) - filter.add("cuckoo", "filter") +----- -**Create Count-Min Sketch and get information** +RediSearch Commands +******************* + +These are the commands for interacting with the `RediSearch module <https://redisearch.io>`_. Below is a brief example, as well as documentation on the commands themselves. + +**Create a search index, and display its information** .. code-block:: python import redis - r = redis.cms().initbydim("dim", 1000, 5) - r.cms().incrby("dim", ["foo"], [5]) - r.cms().info("dim") + r = redis.Redis() + r.ft().create_index(TextField("play", weight=5.0), TextField("ball")) + print(r.ft().info()) -**Create a topk list, and access the results** + +.. automodule:: redis.commands.search.commands + :members: SearchCommands + +----- + +RedisTimeSeries Commands +************************ + +These are the commands for interacting with the `RedisTimeSeries module <https://redistimeseries.io>`_. Below is a brief example, as well as documentation on the commands themselves. + + +**Create a timeseries object with 5 second retention** .. code-block:: python import redis - r = redis.topk().reserve("mytopk", 3, 50, 4, 0.9) - info = r.topk().info("mytopk) + r = redis.Redis() + r.timeseries().create(2, retension_msecs=5) + +.. automodule:: redis.commands.timeseries.commands + :members: TimeSeriesCommands + -.. automodule:: redis.commands.bf.commands - :members: BFCommands, CFCommands, CMSCommands, TOPKCommands diff --git a/docs/sentinel_commands.rst b/docs/sentinel_commands.rst deleted file mode 100644 index e5be11e..0000000 --- a/docs/sentinel_commands.rst +++ /dev/null @@ -1,20 +0,0 @@ -Redis Sentinel Commands -======================= - -redis-py can be used together with `Redis -Sentinel <https://redis.io/topics/sentinel>`_ to discover Redis nodes. You -need to have at least one Sentinel daemon running in order to use -redis-py's Sentinel support. - -Connection example (assumes redis redis on the ports listed below): - - >>> from redis import Sentinel - >>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1) - >>> sentinel.discover_master('mymaster') - ('127.0.0.1', 6379) - >>> sentinel.discover_slaves('mymaster') - [('127.0.0.1', 6380)] - - -.. autoclass:: redis.commands.sentinel.SentinelCommands - :members:
\ No newline at end of file diff --git a/redis/client.py b/redis/client.py index 0984a7c..490b06d 100755 --- a/redis/client.py +++ b/redis/client.py @@ -832,6 +832,7 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands): There are several ways to specify a database number. The first value found will be used: + 1. A ``db`` querystring option, e.g. redis://localhost?db=0 2. If using the redis:// or rediss:// schemes, the path argument of the url, e.g. redis://localhost/0 diff --git a/redis/cluster.py b/redis/cluster.py index 5707a9d..ec75274 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -564,6 +564,7 @@ class RedisCluster(RedisClusterCommands): There are several ways to specify a database number. The first value found will be used: + 1. A ``db`` querystring option, e.g. redis://localhost?db=0 2. If using the redis:// or rediss:// schemes, the path argument of the url, e.g. redis://localhost/0 diff --git a/redis/commands/graph/commands.py b/redis/commands/graph/commands.py index e097936..1db8275 100644 --- a/redis/commands/graph/commands.py +++ b/redis/commands/graph/commands.py @@ -35,7 +35,6 @@ class GraphCommands: Args: - ------- q : The query. params : dict @@ -127,7 +126,6 @@ class GraphCommands: Args: - ------- query: The query that will be executed. params: dict diff --git a/redis/commands/search/commands.py b/redis/commands/search/commands.py index 4ec6fc9..d22afeb 100644 --- a/redis/commands/search/commands.py +++ b/redis/commands/search/commands.py @@ -73,12 +73,9 @@ class SearchCommands: ### Parameters: - **fields**: a list of TextField or NumericField objects - - **no_term_offsets**: If true, we will not save term offsets in - the index - - **no_field_flags**: If true, we will not save field flags that - allow searching in specific fields - - **stopwords**: If not None, we create the index with this custom - stopword list. The list can be empty + - **no_term_offsets**: If true, we will not save term offsets in the index + - **no_field_flags**: If true, we will not save field flags that allow searching in specific fields + - **stopwords**: If not None, we create the index with this custom stopword list. The list can be empty For more information: https://oss.redis.com/redisearch/Commands/#ftcreate """ # noqa @@ -132,6 +129,7 @@ class SearchCommands: ### Parameters: - **delete_documents**: If `True`, all documents will be deleted. + For more information: https://oss.redis.com/redisearch/Commands/#ftdropindex """ # noqa keep_str = "" if delete_documents else "KEEPDOCS" @@ -219,27 +217,23 @@ class SearchCommands: ### Parameters - **doc_id**: the id of the saved document. - - **nosave**: if set to true, we just index the document, and don't - save a copy of it. This means that searches will just - return ids. - - **score**: the document ranking, between 0.0 and 1.0 - - **payload**: optional inner-index payload we can save for fast - i access in scoring functions - - **replace**: if True, and the document already is in the index, + - **nosave**: if set to true, we just index the document, and don't \ + save a copy of it. This means that searches will just return ids. + - **score**: the document ranking, between 0.0 and 1.0. + - **payload**: optional inner-index payload we can save for fast access in scoring functions + - **replace**: if True, and the document already is in the index, \ we perform an update and reindex the document - - **partial**: if True, the fields specified will be added to the - existing document. - This has the added benefit that any fields specified - with `no_index` - will not be reindexed again. Implies `replace` + - **partial**: if True, the fields specified will be added to the \ + existing document. \ + This has the added benefit that any fields specified \ + with `no_index` will not be reindexed again. Implies `replace` - **language**: Specify the language used for document tokenization. - - **no_create**: if True, the document is only updated and reindexed - if it already exists. - If the document does not exist, an error will be - returned. Implies `replace` - - **fields** kwargs dictionary of the document fields to be saved - and/or indexed. - NOTE: Geo points shoule be encoded as strings of "lon,lat" + - **no_create**: if True, the document is only updated and reindexed \ + if it already exists. If the document does not exist, an error will be \ + returned. Implies `replace` + - **fields** kwargs dictionary of the document fields to be saved and/or indexed. + + NOTE: Geo points shoule be encoded as strings of "lon,lat" For more information: https://oss.redis.com/redisearch/Commands/#ftadd """ # noqa @@ -487,7 +481,7 @@ class SearchCommands: **query**: search query. **distance***: the maximal Levenshtein distance for spelling - suggestions (default: 1, max: 4). + suggestions (default: 1, max: 4). **include**: specifies an inclusion custom dictionary. **exclude**: specifies an exclusion custom dictionary. diff --git a/redis/connection.py b/redis/connection.py index bde74b1..8fdb4bd 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -1145,11 +1145,11 @@ def parse_url(url): class ConnectionPool: """ Create a connection pool. ``If max_connections`` is set, then this - object raises :py:class:`~redis.ConnectionError` when the pool's + object raises :py:class:`~redis.exceptions.ConnectionError` when the pool's limit is reached. By default, TCP connections are created unless ``connection_class`` - is specified. Use :py:class:`~redis.UnixDomainSocketConnection` for + is specified. Use class:`.UnixDomainSocketConnection` for unix sockets. Any additional keyword arguments are passed to the constructor of @@ -1181,6 +1181,7 @@ class ConnectionPool: There are several ways to specify a database number. The first value found will be used: + 1. A ``db`` querystring option, e.g. redis://localhost?db=0 2. If using the redis:// or rediss:// schemes, the path argument of the url, e.g. redis://localhost/0 diff --git a/redis/sentinel.py b/redis/sentinel.py index c9383d3..025ab39 100644 --- a/redis/sentinel.py +++ b/redis/sentinel.py @@ -190,7 +190,7 @@ class Sentinel(SentinelCommands): """ Execute Sentinel command in sentinel nodes. once - If set to True, then execute the resulting command on a single - node at random, rather than across the entire sentinel cluster. + node at random, rather than across the entire sentinel cluster. """ once = bool(kwargs.get("once", False)) if "once" in kwargs.keys(): |