Skip to content
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
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
Redis Client implementation for Python 3.

## Features
- Base Redis Client
- Publish Subscribe Client
- Sentinel Client
- Connection Pool
- Sentinel Backed Connection Pool
- Client & Pool for Redis Cluster
- Bulk Mode (Not supported with Redis Cluster)
- Client & Pool with Static Hash Cluster (Supports Bulk Mode)
- Sentinel Backed Pool with Static Hash Cluster (Supports Bulk Mode)
- Complete Synchronous and Asynchronous (asyncio) counterparts for all client and pool classes.
- Base Redis Client & AsyncClient
- Publish Subscribe Client & AsyncPubSubClient
- Sentinel Client & AsyncSentinelClient
- Connection Pool & AsyncPool
- Sentinel Backed Connection Pool & AsyncSentinelPool
- Client & Pool for Redis Cluster & AsyncClusterPool
- Bulk Mode (Sync & Async, not supported with Redis Cluster)
- Client & Pool with Static Hash Cluster & AsyncHashPool
- Sentinel Backed Pool with Static Hash Cluster & AsyncSentinelHashPool

## Documentation
Documentation can be found on GitHub Pages:
Expand Down
3 changes: 3 additions & 0 deletions docs/api/client/async_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncClient

::: pyredis.AsyncClient
3 changes: 3 additions & 0 deletions docs/api/client/async_cluster_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncClusterClient

::: pyredis.AsyncClusterClient
3 changes: 3 additions & 0 deletions docs/api/client/async_hash_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncHashClient

::: pyredis.AsyncHashClient
3 changes: 3 additions & 0 deletions docs/api/client/async_pubsub_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncPubSubClient

::: pyredis.AsyncPubSubClient
3 changes: 3 additions & 0 deletions docs/api/client/async_sentinel_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncSentinelClient

::: pyredis.AsyncSentinelClient
3 changes: 3 additions & 0 deletions docs/api/client/client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Client

::: pyredis.Client
3 changes: 3 additions & 0 deletions docs/api/client/cluster_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ClusterClient

::: pyredis.ClusterClient
3 changes: 3 additions & 0 deletions docs/api/client/hash_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# HashClient

::: pyredis.HashClient
3 changes: 3 additions & 0 deletions docs/api/client/pubsub_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# PubSubClient

::: pyredis.PubSubClient
3 changes: 3 additions & 0 deletions docs/api/client/sentinel_client.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SentinelClient

::: pyredis.SentinelClient
3 changes: 3 additions & 0 deletions docs/api/commands/connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Connection Commands

::: pyredis.commands.Connection
3 changes: 3 additions & 0 deletions docs/api/commands/geo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Geo Commands

::: pyredis.commands.Geo
3 changes: 3 additions & 0 deletions docs/api/commands/hash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Hash Commands

::: pyredis.commands.Hash
3 changes: 3 additions & 0 deletions docs/api/commands/hyperloglog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# HyperLogLog Commands

::: pyredis.commands.HyperLogLog
3 changes: 3 additions & 0 deletions docs/api/commands/key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Key Commands

::: pyredis.commands.Key
3 changes: 3 additions & 0 deletions docs/api/commands/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# List Commands

::: pyredis.commands.List
3 changes: 3 additions & 0 deletions docs/api/commands/publish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Publish Commands

::: pyredis.commands.Publish
3 changes: 3 additions & 0 deletions docs/api/commands/scripting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Scripting Commands

::: pyredis.commands.Scripting
3 changes: 3 additions & 0 deletions docs/api/commands/set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Set Commands

::: pyredis.commands.Set
3 changes: 3 additions & 0 deletions docs/api/commands/sset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SSet Commands

::: pyredis.commands.SSet
3 changes: 3 additions & 0 deletions docs/api/commands/string.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# String Commands

::: pyredis.commands.String
3 changes: 3 additions & 0 deletions docs/api/commands/subscribe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Subscribe Commands

::: pyredis.commands.Subscribe
3 changes: 3 additions & 0 deletions docs/api/commands/transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Transaction Commands

::: pyredis.commands.Transaction
3 changes: 3 additions & 0 deletions docs/api/connection/async_connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncConnection

::: pyredis.connection.AsyncConnection
3 changes: 3 additions & 0 deletions docs/api/connection/connection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Connection

::: pyredis.connection.Connection
3 changes: 3 additions & 0 deletions docs/api/pool/async_base_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncBasePool

::: pyredis.pool.AsyncBasePool
3 changes: 3 additions & 0 deletions docs/api/pool/async_cluster_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncClusterPool

::: pyredis.AsyncClusterPool
3 changes: 3 additions & 0 deletions docs/api/pool/async_hash_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncHashPool

::: pyredis.AsyncHashPool
3 changes: 3 additions & 0 deletions docs/api/pool/async_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncPool

::: pyredis.AsyncPool
3 changes: 3 additions & 0 deletions docs/api/pool/async_sentinel_hash_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncSentinelHashPool

::: pyredis.AsyncSentinelHashPool
3 changes: 3 additions & 0 deletions docs/api/pool/async_sentinel_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# AsyncSentinelPool

::: pyredis.AsyncSentinelPool
3 changes: 3 additions & 0 deletions docs/api/pool/base_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# BasePool

::: pyredis.pool.BasePool
3 changes: 3 additions & 0 deletions docs/api/pool/cluster_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ClusterPool

::: pyredis.ClusterPool
3 changes: 3 additions & 0 deletions docs/api/pool/hash_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# HashPool

::: pyredis.HashPool
3 changes: 3 additions & 0 deletions docs/api/pool/pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pool

::: pyredis.Pool
3 changes: 3 additions & 0 deletions docs/api/pool/sentinel_hash_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SentinelHashPool

::: pyredis.SentinelHashPool
3 changes: 3 additions & 0 deletions docs/api/pool/sentinel_pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SentinelPool

::: pyredis.SentinelPool
156 changes: 156 additions & 0 deletions docs/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,159 @@ client.publish('/blub', 'test')
subscribe.get()
[b'message', b'/blub', b'test']
```

## Asynchronous Client and Pool Usage

### Simple Async Client Usage

```python
import asyncio
from pyredis import AsyncClient

async def main():
client = AsyncClient(host="localhost")
await client.ping()
await client.close()

asyncio.run(main())
```

### Async Bulk Mode

```python
import asyncio
from pyredis import AsyncClient

async def main():
client = AsyncClient(host="localhost")
await client.bulk_start()
await client.set("key1", "value1")
await client.set("key2", "value2")
await client.set("key3", "value3")
results = await client.bulk_stop()
print(results)
await client.close()

asyncio.run(main())
```

### Using an Async Connection Pool

```python
import asyncio
from pyredis import AsyncPool

async def main():
pool = AsyncPool(host="localhost")
client = await pool.acquire()
await client.ping()
await pool.release(client)

asyncio.run(main())
```

### Using an Async Cluster Connection Pool

```python
import asyncio
from pyredis import AsyncClusterPool

async def main():
pool = AsyncClusterPool(
seeds=[
("seed1", 6379),
("seed2", 6379)
]
)
client = await pool.acquire()
await client.ping(shard_key="test")
await pool.release(client)

asyncio.run(main())
```

### Using an Async Hash Connection Pool

```python
import asyncio
from pyredis import AsyncHashPool

async def main():
pool = AsyncHashPool(
buckets=[
("host1", 6379),
("host2", 6379)
]
)
client = await pool.acquire()
await client.ping(shard_key="test")
await pool.release(client)

asyncio.run(main())
```

### Using an Async Sentinel backed Connection Pool

```python
import asyncio
from pyredis import AsyncSentinelPool

async def main():
pool = AsyncSentinelPool(
sentinels=[
("sentinel1", 26379),
("sentinel2", 26379)
],
name="mymaster"
)
client = await pool.acquire()
await client.ping()
await pool.release(client)

asyncio.run(main())
```

### Getting Async Pools/Clients by URL

```python
from pyredis import get_by_url

pool = get_by_url(
url="redis://localhost?password=topsecret",
async_client=True
)

pubsub = get_by_url(
url="pubsub://localhost?password=topsecret",
async_client=True
)
```

### Async Publish Subscribe

```python
import asyncio
from pyredis import AsyncClient
from pyredis import AsyncPubSubClient

async def main():
client = AsyncClient(host="localhost")
subscribe = AsyncPubSubClient(host="localhost")

await subscribe.subscribe("/blub")
res1 = await subscribe.get()
print(res1)

await client.publish(
"/blub",
"test"
)
res2 = await subscribe.get()
print(res2)

await client.close()
await subscribe.close()

asyncio.run(main())
```

Loading
Loading