Skip to content

Commit bc3dbb4

Browse files
authored
Documentation cleanup (#1841)
1 parent deaaa53 commit bc3dbb4

File tree

13 files changed

+149
-133
lines changed

13 files changed

+149
-133
lines changed

docs/commands.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Redis Commands
2+
##############
3+
4+
Core Commands
5+
*************
6+
7+
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:
8+
9+
Getting and settings data in redis::
10+
11+
import redis
12+
r = redis.Redis(decode_responses=True)
13+
r.set('mykey', 'thevalueofmykey')
14+
r.get('mykey')
15+
16+
.. autoclass:: redis.commands.core.CoreCommands
17+
:inherited-members:
18+
19+
Sentinel Commands
20+
*****************
21+
.. autoclass:: redis.commands.sentinel.SentinelCommands
22+
:inherited-members:
23+
24+
Redis Cluster Commands
25+
**********************
26+
27+
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.
28+
29+
.. autoclass:: redis.commands.cluster.RedisClusterCommands
30+
:inherited-members:

docs/connections.rst

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,41 @@ Connecting to Redis
33

44
Generic Client
55
**************
6-
.. autoclass:: redis.client.Redis
6+
7+
This is the client used to connect directly to a standard redis node.
8+
9+
.. autoclass:: redis.Redis
10+
:members:
11+
12+
Sentinel Client
13+
***************
14+
15+
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.
16+
17+
Connection example (assumes redis redis on the ports listed below):
18+
19+
>>> from redis import Sentinel
20+
>>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1)
21+
>>> sentinel.discover_master('mymaster')
22+
('127.0.0.1', 6379)
23+
>>> sentinel.discover_slaves('mymaster')
24+
[('127.0.0.1', 6380)]
25+
26+
.. autoclass:: redis.sentinel.Sentinel
27+
:members:
28+
29+
.. autoclass:: redis.sentinel.SentinelConnectionPool
30+
:members:
31+
32+
Cluster Client
33+
**************
34+
35+
This client is used for connecting to a redis cluser.
36+
37+
.. autoclass:: redis.cluster.RedisCluster
738
:members:
839

940
Connection Pools
1041
*****************
1142
.. autoclass:: redis.connection.ConnectionPool
12-
:members:
43+
:members:

docs/index.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ Redis Command Functions
5656
.. toctree::
5757
:maxdepth: 2
5858

59-
redis_commands
60-
redis_cluster_commands
61-
sentinel_commands
59+
commands
6260
redismodules
6361

6462
Module Documentation

docs/redis_cluster_commands.rst

Lines changed: 0 additions & 7 deletions
This file was deleted.

docs/redis_commands.rst

Lines changed: 0 additions & 14 deletions
This file was deleted.

docs/redismodules.rst

Lines changed: 59 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,49 @@ Redis Modules Commands
33

44
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>`_.
55

6-
RedisTimeSeries Commands
7-
************************
86

9-
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.
7+
RedisBloom Commands
8+
*******************
109

10+
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.
1111

12-
**Create a timeseries object with 5 second retention**
12+
**Create and add to a bloom filter**
1313

1414
.. code-block:: python
1515
1616
import redis
17-
r = redis.Redis()
18-
r.timeseries().create(2, retension_msecs=5)
19-
20-
.. automodule:: redis.commands.timeseries.commands
21-
:members: TimeSeriesCommands
22-
23-
-----
24-
25-
RedisJSON Commands
26-
******************
27-
28-
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.
17+
filter = redis.bf().create("bloom", 0.01, 1000)
18+
filter.add("bloom", "foo")
2919
30-
**Create a json object**
20+
**Create and add to a cuckoo filter**
3121

3222
.. code-block:: python
3323
3424
import redis
35-
r = redis.Redis()
36-
r.json().set("mykey", ".", {"hello": "world", "i am": ["a", "json", "object!"]}
37-
38-
39-
.. automodule:: redis.commands.json.commands
40-
:members: JSONCommands
25+
filter = redis.cf().create("cuckoo", 1000)
26+
filter.add("cuckoo", "filter")
4127
42-
-----
28+
**Create Count-Min Sketch and get information**
4329

44-
RediSearch Commands
45-
*******************
30+
.. code-block:: python
4631
47-
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.
32+
import redis
33+
r = redis.cms().initbydim("dim", 1000, 5)
34+
r.cms().incrby("dim", ["foo"], [5])
35+
r.cms().info("dim")
4836
49-
**Create a search index, and display its information**
37+
**Create a topk list, and access the results**
5038

5139
.. code-block:: python
5240
5341
import redis
54-
r = redis.Redis()
55-
r.ft().create_index(TextField("play", weight=5.0), TextField("ball"))
56-
print(r.ft().info())
57-
42+
r = redis.topk().reserve("mytopk", 3, 50, 4, 0.9)
43+
info = r.topk().info("mytopk)
5844
59-
.. automodule:: redis.commands.search.commands
60-
:members: SearchCommands
45+
.. automodule:: redis.commands.bf.commands
46+
:members: BFCommands, CFCommands, CMSCommands, TOPKCommands
6147
62-
-----
48+
------
6349
6450
RedisGraph Commands
6551
*******************
@@ -92,45 +78,62 @@ These are the commands for interacting with the `RedisGraph module <https://redi
9278
.. automodule:: redis.commands.graph.commands
9379
:members: GraphCommands
9480
95-
-----
81+
------
9682
97-
RedisBloom Commands
98-
*******************
83+
RedisJSON Commands
84+
******************
9985
100-
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.
86+
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.
10187
102-
**Create and add to a bloom filter**
88+
**Create a json object**
10389
10490
.. code-block:: python
10591
10692
import redis
107-
filter = redis.bf().create("bloom", 0.01, 1000)
108-
filter.add("bloom", "foo")
93+
r = redis.Redis()
94+
r.json().set("mykey", ".", {"hello": "world", "i am": ["a", "json", "object!"]}
10995
110-
**Create and add to a cuckoo filter**
11196
112-
.. code-block:: python
97+
.. automodule:: redis.commands.json.commands
98+
:members: JSONCommands
11399
114-
import redis
115-
filter = redis.cf().create("cuckoo", 1000)
116-
filter.add("cuckoo", "filter")
100+
-----
117101
118-
**Create Count-Min Sketch and get information**
102+
RediSearch Commands
103+
*******************
104+
105+
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.
106+
107+
**Create a search index, and display its information**
119108
120109
.. code-block:: python
121110
122111
import redis
123-
r = redis.cms().initbydim("dim", 1000, 5)
124-
r.cms().incrby("dim", ["foo"], [5])
125-
r.cms().info("dim")
112+
r = redis.Redis()
113+
r.ft().create_index(TextField("play", weight=5.0), TextField("ball"))
114+
print(r.ft().info())
126115
127-
**Create a topk list, and access the results**
116+
117+
.. automodule:: redis.commands.search.commands
118+
:members: SearchCommands
119+
120+
-----
121+
122+
RedisTimeSeries Commands
123+
************************
124+
125+
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.
126+
127+
128+
**Create a timeseries object with 5 second retention**
128129
129130
.. code-block:: python
130131
131132
import redis
132-
r = redis.topk().reserve("mytopk", 3, 50, 4, 0.9)
133-
info = r.topk().info("mytopk)
133+
r = redis.Redis()
134+
r.timeseries().create(2, retension_msecs=5)
135+
136+
.. automodule:: redis.commands.timeseries.commands
137+
:members: TimeSeriesCommands
138+
134139
135-
.. automodule:: redis.commands.bf.commands
136-
:members: BFCommands, CFCommands, CMSCommands, TOPKCommands

docs/sentinel_commands.rst

Lines changed: 0 additions & 20 deletions
This file was deleted.

redis/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,7 @@ def from_url(cls, url, **kwargs):
832832
833833
There are several ways to specify a database number. The first value
834834
found will be used:
835+
835836
1. A ``db`` querystring option, e.g. redis://localhost?db=0
836837
2. If using the redis:// or rediss:// schemes, the path argument
837838
of the url, e.g. redis://localhost/0

redis/cluster.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ def from_url(cls, url, **kwargs):
564564
565565
There are several ways to specify a database number. The first value
566566
found will be used:
567+
567568
1. A ``db`` querystring option, e.g. redis://localhost?db=0
568569
2. If using the redis:// or rediss:// schemes, the path argument
569570
of the url, e.g. redis://localhost/0

redis/commands/graph/commands.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def query(self, q, params=None, timeout=None, read_only=False, profile=False):
3535
3636
Args:
3737
38-
-------
3938
q :
4039
The query.
4140
params : dict
@@ -127,7 +126,6 @@ def explain(self, query, params=None):
127126
128127
Args:
129128
130-
-------
131129
query:
132130
The query that will be executed.
133131
params: dict

0 commit comments

Comments
 (0)