Skip to content

Docstrings for the commands #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions upstash_redis/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@


class Redis(AsyncCommands):
"""
A Redis client that uses the Upstash REST API.

```python
from upstash_redis.asyncio import Redis

redis = Redis.from_env()

await redis.set("key", "value")
await redis.get("key")
```

To use the blocking client, use `upstash_redis.Redis`.
"""

def __init__(
self,
url: str,
Expand All @@ -20,6 +35,8 @@ def __init__(
allow_telemetry: bool = True,
):
"""
Creates a new async Redis client.

:param url: UPSTASH_REDIS_REST_URL in the console
:param token: UPSTASH_REDIS_REST_TOKEN in the console
:param rest_encoding: the encoding that can be used by the REST API to parse the response before sending it
Expand Down
21 changes: 20 additions & 1 deletion upstash_redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@


class Redis(Commands):
"""
A Redis client that uses the Upstash REST API.

Blocking example:

```python
from upstash_redis import Redis

redis = Redis.from_env()

redis.set("key", "value")
redis.get("key")
```

To use the async client, use `upstash_redis.asyncio.Redis`.
"""

def __init__(
self,
url: str,
Expand All @@ -20,6 +37,8 @@ def __init__(
allow_telemetry: bool = True,
):
"""
Creates a new blocking Redis client.

:param url: UPSTASH_REDIS_REST_URL in the console
:param token: UPSTASH_REDIS_REST_TOKEN in the console
:param rest_encoding: the encoding that can be used by the REST API to parse the response before sending it
Expand All @@ -33,7 +52,7 @@ def __init__(

self._allow_telemetry = allow_telemetry

self._rest_encoding = rest_encoding
self._rest_encoding: Union[Literal["base64"], None] = rest_encoding
self._rest_retries = rest_retries
self._rest_retry_interval = rest_retry_interval

Expand Down
Loading