Skip to content

Instantly share code, notes, and snippets.

@roguh
Last active February 4, 2022 16:47
Show Gist options
  • Save roguh/44efdbcb9dbc7595fd6a5f58fe1bbf0f to your computer and use it in GitHub Desktop.
Save roguh/44efdbcb9dbc7595fd6a5f58fe1bbf0f to your computer and use it in GitHub Desktop.
Connect to a redis sentinel
from redis.sentinel import Sentinel
def connect_to_redis(address: str, port: int, redis_set: str):
sentinel = Sentinel([(address, port)], socket_timeout=0.5)
con = sentinel.master_for(
redis_set,
decode_responses=True,
socket_timeout=0.5,
)
con.echo("test")
return con
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment