Skip to main content

prefect_redis.client

Functions

is_cluster_url

Return True if the URL uses the Redis Cluster scheme.

normalize_cluster_url

Return a redis-py compatible URL for Redis Cluster connections.

cluster_key_prefix

Return a key prefix, hash-tagged when configured for Redis Cluster.

redis_key

Return a Redis key rooted at a cluster-aware prefix.

cached

close_all_cached_connections

Close all cached Redis connections. Sentinel-backed clients hold one extra Redis client per Sentinel daemon, so the daemon-aware aclose_redis_client is used rather than a bare client.aclose().

clear_cached_clients

Clear cached Redis clients and the messaging URL lookup.

get_async_redis_client

Retrieves an async Redis client. When a url is provided (or configured via PREFECT_REDIS_MESSAGING_URL) the discrete host/port/… arguments are ignored. Standalone URLs are passed to Redis.from_url; redis+sentinel:// and rediss+sentinel:// URLs resolve the current master through the listed Sentinel daemons and follow failover automatically. URL query options override the settings-derived connection defaults. Redis Cluster URLs are detected but intentionally not enabled yet. Args:
  • url: Full Redis URL (e.g. redis\://localhost\:6379/0 or redis+sentinel\://sentinel-a\:26379,sentinel-b\:26379/mymaster).
  • host: The host location.
  • port: The port to connect to the host with.
  • db: The Redis database to interact with.
  • password: The password for the redis host
  • username: Username for the redis instance
  • health_check_interval: Health check interval in seconds.
  • decode_responses: Whether to decode binary responses from Redis to unicode strings.
  • ssl: Whether to use SSL for the connection.
  • socket_timeout: Timeout for socket read operations (None = no timeout).
  • socket_connect_timeout: Timeout for socket connect (None = no timeout).
  • protocol: RESP protocol version (default 2 from settings).
Returns:
  • a Redis client

async_redis_from_settings

Classes

RedisMessagingSettings

Settings for connecting to Redis. Connection can be configured either via a single url field (e.g. redis://user:pass@host:6379/0) or with the individual host/port/db/… fields. When url is set it takes precedence and the discrete fields are ignored. Environment variable: PREFECT_REDIS_MESSAGING_URL