<@ULVA73B9P> Prefect is compatible with redis sent...
# ask-marvin
l
@Marvin Prefect is compatible with redis sentinel?
m
thought for 159.9 seconds
Short answer: not natively. Prefect doesn’t provide built‑in Redis Sentinel support in its Redis blocks/integrations (Prefect 3.x or 2.x). The official Redis blocks expect a single Redis URL/host:port and do not expose Sentinel settings. Ways you can use Sentinel with Prefect: - Put a stable endpoint in front of Sentinel (e.g., TCP load balancer/virtual IP that always points at the current master) and configure Prefect to use that host:port. This keeps Prefect unchanged. - Use redis‑py’s Sentinel client directly in your own tasks/flows (bypassing Prefect’s Redis blocks). Example:
Copy code
from redis.sentinel import Sentinel
from prefect import flow, task

def get_redis():
    sentinels = [("sentinel-1", 26379), ("sentinel-2", 26379), ("sentinel-3", 26379)]
    s = Sentinel(sentinels, socket_timeout=0.5)  # add password/db kwargs if needed
    return s.master_for("mymaster", decode_responses=True)

@task
def set_value(key, value):
    r = get_redis()
    r.set(key, value)

@task
def get_value(key):
    r = get_redis()
    return r.get(key)

@flow
def demo():
    set_value("example", "42")
    v = get_value("example")
    print(v)

if __name__ == "__main__":
    demo()
- If you want UI‑managed credentials like a Block, create a small custom Prefect block that stores Sentinel hosts and returns a
redis.sentinel.Sentinel(...).master_for(...)
client. References: - Prefect Redis integration overview: Prefect Redis integration - Prefect custom blocks guide: Creating custom blocks - redis‑py Sentinel docs: redis-py Sentinel If you can share how you plan to use Redis with Prefect (caching, concurrency limits/leases, or general data ops), I can suggest the cleanest Sentinel-compatible setup or sketch a custom block for you.