docs/integrations/prefect-redis/api-ref/prefect_redis-blocks.mdx
prefect_redis.blocksRedis credentials handling
RedisDatabase <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L17" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>Block used to manage authentication with a Redis database
Attributes:
host: The host of the Redis serverport: The port the Redis server is running ondb: The database to write to and read fromusername: The username to use when connecting to the Redis serverpassword: The password to use when connecting to the Redis serverssl: Whether to use SSL when connecting to the Redis serverkey_ttl: Optional per-key TTL in seconds applied to every written key
(SET ... EX); None (default) means keys never expireMethods:
aread_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L85" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>aread_path(self, path: str) -> bytes
Read a redis key
Args:
path: Redis key to read fromReturns:
Examples:
Read a key:
python content = await block.aread_path("my-key")
as_connection_params <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L228" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>as_connection_params(self) -> Dict[str, Any]
Return a dictionary suitable for unpacking
awrite_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L128" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>awrite_path(self, path: str, content: bytes) -> bool
Write to a redis key
Args:
path: Redis key to write tocontent: Binary object to writeExamples:
Write a key:
python await block.awrite_path("my-key", b"contents")
block_initialization <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L77" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>block_initialization(self) -> None
Validate parameters
from_connection_string <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L198" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>from_connection_string(cls, connection_string: Union[str, SecretStr]) -> 'RedisDatabase'
Create block from a Redis connection string
Supports the following URL schemes:
redis:// creates a TCP socket connectionrediss:// creates a SSL wrapped TCP socket connectionArgs:
connection_string: Redis connection stringReturns:
RedisCredentials instanceget_async_client <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L182" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_async_client(self) -> redis.asyncio.Redis
Get Redis Client
Returns:
get_client <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L167" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>get_client(self) -> redis.Redis
Get Redis Client
Returns:
read_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L107" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>read_path(self, path: str) -> bytes
Read a redis key
Args:
path: Redis key to read fromReturns:
Examples:
Read a key:
python content = block.read_path("my-key")
write_path <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-redis/prefect_redis/blocks.py#L148" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>write_path(self, path: str, content: bytes) -> bool
Write to a redis key
Args:
path: Redis key to write tocontent: Binary object to writeExamples:
Write a key:
python block.write_path("my-key", b"contents")