Skip to content

Latest commit

 

History

History
117 lines (81 loc) · 2.47 KB

connections.rst

File metadata and controls

117 lines (81 loc) · 2.47 KB

Connecting to Redis

Generic Client

This is the client used to connect directly to a standard Redis node.

redis.Redis

Sentinel Client

Redis 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 exists 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)]

Sentinel

redis.sentinel.Sentinel

SentinelConnectionPool

redis.sentinel.SentinelConnectionPool

Cluster Client

This client is used for connecting to a Redis Cluster.

RedisCluster

redis.cluster.RedisCluster

ClusterNode

redis.cluster.ClusterNode

Async Client

See complete example: here

This client is used for communicating with Redis, asynchronously.

redis.asyncio.client.Redis

Async Cluster Client

RedisCluster (Async)

redis.asyncio.cluster.RedisCluster

ClusterNode (Async)

redis.asyncio.cluster.ClusterNode

ClusterPipeline (Async)

redis.asyncio.cluster.ClusterPipeline

Connection

See complete example: here

Connection

redis.connection.Connection

Connection (Async)

redis.asyncio.connection.Connection

Connection Pools

See complete example: here

ConnectionPool

redis.connection.ConnectionPool

ConnectionPool (Async)

redis.asyncio.connection.ConnectionPool