Skip to content

Commit 12c17bf

Browse files
authored
Adding cluster, bloom, and graph docs (#1779)
1 parent a58f423 commit 12c17bf

File tree

6 files changed

+152
-12
lines changed

6 files changed

+152
-12
lines changed

docs/index.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,30 @@ redis-py can be installed using pip via ``pip install redis``.
1616

1717

1818
Quickly connecting to redis
19-
************
19+
***************************
2020

2121
There are two quick ways to connect to Redis.
2222

23-
Assuming you run Redis on localhost:6379 (the default)::
23+
**Assuming you run Redis on localhost:6379 (the default)**
24+
25+
.. code-block:: python
26+
2427
import redis
2528
r = redis.Redis()
2629
r.ping()
2730
28-
Running redis on foo.bar.com, port 12345::
31+
**Running redis on foo.bar.com, port 12345**
32+
33+
.. code-block:: python
34+
2935
import redis
3036
r = redis.Redis(host='foo.bar.com', port=12345)
3137
r.ping()
3238
33-
Another example with foo.bar.com, port 12345::
39+
**Another example with foo.bar.com, port 12345**
40+
41+
.. code-block:: python
42+
3443
import redis
3544
r = redis.from_url('redis://foo.bar.com:12345')
3645
r.ping()
@@ -47,7 +56,8 @@ Redis Command Functions
4756
.. toctree::
4857
:maxdepth: 2
4958

50-
redis_core_commands
59+
redis_commands
60+
redis_cluster_commands
5161
sentinel_commands
5262
redismodules
5363

docs/redis_cluster_commands.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Redis Cluster Commands
2+
######################
3+
4+
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.
5+
6+
.. autoclass:: redis.commands.cluster.RedisClusterCommands
7+
:inherited-members:

docs/redis_core_commands.rst renamed to docs/redis_commands.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Redis Core Commands
2-
####################
1+
Redis Commands
2+
###############
33

44
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:
55

@@ -11,4 +11,4 @@ Getting and settings data in redis::
1111
r.get('mykey')
1212

1313
.. autoclass:: redis.commands.core.CoreCommands
14-
:members:
14+
:inherited-members:

docs/redismodules.rst

Lines changed: 120 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,132 @@ Accessing redis module commands requires the installation of the supported `Redi
55

66
RedisTimeSeries Commands
77
************************
8+
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.
10+
11+
12+
**Create a timeseries object with 5 second retention**
13+
14+
.. code-block:: python
15+
16+
import redis
17+
r = redis.Redis()
18+
r.timeseries().create(2, retension_msecs=5)
19+
820
.. automodule:: redis.commands.timeseries.commands
9-
:members: TimeSeriesCommands
21+
:members: TimeSeriesCommands
22+
23+
-----
1024

1125
RedisJSON Commands
1226
******************
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.
29+
30+
**Create a json object**
31+
32+
.. code-block:: python
33+
34+
import redis
35+
r = redis.Redis()
36+
r.json().set("mykey", ".", {"hello": "world", "i am": ["a", "json", "object!"]}
37+
38+
1339
.. automodule:: redis.commands.json.commands
14-
:members: JSONCommands
40+
:members: JSONCommands
41+
42+
-----
1543
1644
RediSearch Commands
1745
*******************
46+
47+
These are the commands for interacting with the `RediSearch module <https://redisjson.io>`_. Below is a brief example, as well as documentation on the commands themselves.
48+
49+
**Create a search index, and display its information**
50+
51+
.. code-block:: python
52+
53+
import redis
54+
r = redis.Redis()
55+
r.ft().create_index(TextField("play", weight=5.0), TextField("ball"))
56+
print(r.ft().info())
57+
58+
1859
.. automodule:: redis.commands.search.commands
19-
:members: SearchCommands
60+
:members: SearchCommands
61+
62+
-----
63+
64+
RedisGraph Commands
65+
*******************
66+
67+
These are the commands for interacting with the `RedisGraph module <https://redisjson.io>`_. Below is a brief example, as well as documentation on the commands themselves.
68+
69+
**Create a graph, adding two nodes**
70+
71+
.. code-block:: python
72+
73+
import redis
74+
from redis.graph.node import Node
75+
76+
john = Node(label="person", properties={"name": "John Doe", "age": 33}
77+
jane = Node(label="person", properties={"name": "Jane Doe", "age": 34}
78+
79+
r = redis.Redis()
80+
graph = r.graph()
81+
graph.add_node(john)
82+
graph.add_node(jane)
83+
graph.add_node(pat)
84+
graph.commit()
85+
86+
.. automodule:: redis.commands.graph.node
87+
:members: Node
88+
89+
.. automodule:: redis.commands.graph.edge
90+
:members: Edge
91+
92+
.. automodule:: redis.commands.graph.commands
93+
:members: GraphCommands
94+
95+
-----
96+
97+
RedisBloom Commands
98+
*******************
99+
100+
These are the commands for interacting with the `RedisBloom module <https://redisjson.io>`_. Below is a brief example, as well as documentation on the commands themselves.
101+
102+
**Create and add to a bloom filter**
103+
104+
.. code-block:: python
105+
106+
import redis
107+
filter = redis.bf().create("bloom", 0.01, 1000)
108+
filter.add("bloom", "foo")
109+
110+
**Create and add to a cuckoo filter**
111+
112+
.. code-block:: python
113+
114+
import redis
115+
filter = redis.cf().create("cuckoo", 1000)
116+
filter.add("cuckoo", "filter")
117+
118+
**Create Count-Min Sketch and get information**
119+
120+
.. code-block:: python
121+
122+
import redis
123+
r = redis.cms().initbydim("dim", 1000, 5)
124+
r.cms().incrby("dim", ["foo"], [5])
125+
r.cms().info("dim")
126+
127+
**Create a topk list, and access the results**
128+
129+
.. code-block:: python
130+
131+
import redis
132+
r = redis.topk().reserve("mytopk", 3, 50, 4, 0.9)
133+
info = r.topk().info("mytopk)
134+
135+
.. automodule:: redis.commands.bf.commands
136+
:members: BFCommands, CFCommands, CMSCommands, TOPKCommands

redis/commands/bf/commands.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252

5353
class BFCommands:
54-
"""RedisBloom commands."""
54+
"""Bloom Filter commands."""
5555

5656
# region Bloom Filter Functions
5757
def create(self, key, errorRate, capacity, expansion=None, noScale=None):
@@ -166,6 +166,7 @@ def info(self, key):
166166

167167

168168
class CFCommands:
169+
"""Cuckoo Filter commands."""
169170

170171
# region Cuckoo Filter Functions
171172
def create(
@@ -283,6 +284,8 @@ def info(self, key):
283284

284285

285286
class TOPKCommands:
287+
"""TOP-k Filter commands."""
288+
286289
def reserve(self, key, k, width, depth, decay):
287290
"""
288291
Create a new Top-K Filter `key` with desired probability of false
@@ -432,6 +435,7 @@ def info(self, key):
432435

433436

434437
class CMSCommands:
438+
"""Count-Min Sketch Commands"""
435439

436440
# region Count-Min Sketch Functions
437441
def initbydim(self, key, width, depth):

redis/commands/graph/commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77

88
class GraphCommands:
9+
"""RedisGraph Commands"""
10+
911
def commit(self):
1012
"""
1113
Create entire graph.

0 commit comments

Comments
 (0)