Skip to content

Commit

Permalink
Documentation cleanup (#1841)
Browse files Browse the repository at this point in the history
  • Loading branch information
chayim committed Dec 30, 2021
1 parent deaaa53 commit bc3dbb4
Show file tree
Hide file tree
Showing 13 changed files with 149 additions and 133 deletions.
30 changes: 30 additions & 0 deletions docs/commands.rst
Original file line number Diff line number Diff line change
@@ -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:
35 changes: 33 additions & 2 deletions docs/connections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
:members:
4 changes: 1 addition & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ Redis Command Functions
.. toctree::
:maxdepth: 2

redis_commands
redis_cluster_commands
sentinel_commands
commands
redismodules

Module Documentation
Expand Down
7 changes: 0 additions & 7 deletions docs/redis_cluster_commands.rst

This file was deleted.

14 changes: 0 additions & 14 deletions docs/redis_commands.rst

This file was deleted.

115 changes: 59 additions & 56 deletions docs/redismodules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
*******************
Expand Down Expand Up @@ -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
20 changes: 0 additions & 20 deletions docs/sentinel_commands.rst

This file was deleted.

1 change: 1 addition & 0 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ def from_url(cls, url, **kwargs):
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
Expand Down
1 change: 1 addition & 0 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ def from_url(cls, url, **kwargs):
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
Expand Down
2 changes: 0 additions & 2 deletions redis/commands/graph/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def query(self, q, params=None, timeout=None, read_only=False, profile=False):
Args:
-------
q :
The query.
params : dict
Expand Down Expand Up @@ -127,7 +126,6 @@ def explain(self, query, params=None):
Args:
-------
query:
The query that will be executed.
params: dict
Expand Down

0 comments on commit bc3dbb4

Please sign in to comment.