Skip to main content

prefect_redis.blocks

Redis credentials handling

Classes

RedisDatabase

Block used to manage authentication with a Redis database Attributes:
  • host: The host of the Redis server
  • port: The port the Redis server is running on
  • db: The database to write to and read from
  • username: The username to use when connecting to the Redis server
  • password: The password to use when connecting to the Redis server
  • ssl: Whether to use SSL when connecting to the Redis server
  • key_ttl: Optional per-key TTL in seconds applied to every written key (SET ... EX); None (default) means keys never expire
Methods:

aread_path

Read a redis key Args:
  • path: Redis key to read from
Returns:
  • Contents at key as bytes
Examples: Read a key:

as_connection_params

Return a dictionary suitable for unpacking

awrite_path

Write to a redis key Args:
  • path: Redis key to write to
  • content: Binary object to write
Examples: Write a key:

block_initialization

Validate parameters

from_connection_string

Create block from a Redis connection string Supports the following URL schemes:
  • redis:// creates a TCP socket connection
  • rediss:// creates a SSL wrapped TCP socket connection
Args:
  • connection_string: Redis connection string
Returns:
  • RedisCredentials instance

get_async_client

Get Redis Client Returns:
  • An initialized Redis async client

get_client

Get Redis Client Returns:
  • An initialized Redis async client

read_path

Read a redis key Args:
  • path: Redis key to read from
Returns:
  • Contents at key as bytes
Examples: Read a key:

write_path

Write to a redis key Args:
  • path: Redis key to write to
  • content: Binary object to write
Examples: Write a key: