redis-connect-helper.php

Redis Connection Helper.

Source includes/Support/redis-connect-helper.php3 min readPart of Performance Optimisation

includes/Support/redis-connect-helper.php

Redis Connection Helper.

Lines: 623

function wppo_redis_connect()

function wppo_redis_connect($config)

Establishes a Redis connection according to the provided configuration.

ParameterTypeDefaultDescription
$configarray—Redis configuration. string $mode Connection mode: \’standalone\’, \’sentinel\’, or \’cluster\’. string $host Redis host for standalone mode. int $port Redis port for standalone mode. string $password Password for AUTH, if required. int $database Database index to select (default 0). array|string $nodes Nodes for cluster/sentinel. May be an array or a delimiter-separated string (commas, semicolons, or whitespace). Entries may include host:port; IPv6 with brackets is supported. string $master_name Master name for sentinel mode (default \’mymaster\’). bool $use_tls Whether to use TLS for connections. bool $persistent Use persistent connections for standalone/cluster. string $compression Compression algorithm to configure (one of: \’none\’, \’lzf\’, \’zstd\’, \’lz4\’).

Return: \\Redis|\\RedisCluster|\\WP_Error — A connected Redis client (`Redis` or `RedisCluster`) on success, or a `WP_Error` describing the failure.

Tags: @since 1.4.0

Source: includes/Support/redis-connect-helper.php, line 54

function wppo_redis_connect_cluster()

function wppo_redis_connect_cluster($config)

Establishes a Redis Cluster connection.

ParameterTypeDefaultDescription
$configarray—Redis configuration.

Return: \\RedisCluster|\\WP_Error — A connected RedisCluster client or a WP_Error on failure.

Tags: @since 2.0.0

Source: includes/Support/redis-connect-helper.php, line 102

function wppo_redis_connect_sentinel()

function wppo_redis_connect_sentinel($config)

Establishes a Redis Sentinel connection.

ParameterTypeDefaultDescription
$configarray—Redis configuration.

Return: \\Redis|\\WP_Error — A connected Redis client or a WP_Error on failure.

Tags: @since 2.0.0

Source: includes/Support/redis-connect-helper.php, line 152

function wppo_redis_connect_standalone()

function wppo_redis_connect_standalone($config)

Establishes a standalone Redis connection.

ParameterTypeDefaultDescription
$configarray—Redis configuration.

Return: \\Redis|\\WP_Error — A connected Redis client or a WP_Error on failure.

Tags: @since 2.0.0

Source: includes/Support/redis-connect-helper.php, line 254

function wppo_parse_redis_node()

function wppo_parse_redis_node($node)

Parses a Redis node string into host and port components.

ParameterTypeDefaultDescription
$nodestring—The node string to parse.

Return: array — Associative array containing \’host\’ and \’port\’.

Tags: @since 2.0.0

Source: includes/Support/redis-connect-helper.php, line 305

function wppo_normalize_redis_serializer_choice()

function wppo_normalize_redis_serializer_choice($igbinary_available, =false $msgpack_available)

Map availability probes to a concrete phpredis serializer choice.

ParameterTypeDefaultDescription
$igbinary_availablebool—Whether the igbinary serializer is usable for this build.
$msgpack_available=false—Whether ext-msgpack is available (informational; never selected).

Return: array — Shape { serializer: int, name: string } where name is \’igbinary\’ or \’php\’.

Tags: @since 2.0.0

Source: includes/Support/redis-connect-helper.php, line 362

function wppo_resolve_redis_serializer()

function wppo_resolve_redis_serializer()

Resolve a safe serializer for the current phpredis build.

Return: array — Shape { serializer: int, name: string } where name is \’igbinary\’ or \’php\’.

Tags: @since 2.0.0

Source: includes/Support/redis-connect-helper.php, line 410

function wppo_apply_redis_options()

function wppo_apply_redis_options($redis, $config)

Configure serializer and optional compression on a Redis client based on provided settings.

ParameterTypeDefaultDescription
$redis\\Redis|\\RedisCluster—Redis client instance to configure.
$configarray—Configuration options; recognizes `compression` which may be \”lzf\”, \”zstd\”, \”lz4\”, or \”none\”.

Tags: @since 1.4.0

Source: includes/Support/redis-connect-helper.php, line 459

function wppo_validate_tls_ca_file()

function wppo_validate_tls_ca_file($path)

Validate a TLS CA bundle path for Redis SSL options.

ParameterTypeDefaultDescription
$pathstring—Raw CA file path from config.

Return: string — Resolved path or \’\’ when invalid.

Tags: @since 2.2.0

Source: includes/Support/redis-connect-helper.php, line 558

function wppo_parse_nodes()

function wppo_parse_nodes($nodes)

Normalize a string or array of Redis node specifications into a trimmed list.

ParameterTypeDefaultDescription
$nodesarray|string—Node specifications as a delimited string or an array of strings.

Return: string[] — Trimmed node strings with empty entries removed; returns an empty array for unsupported input.

Tags: @since 1.4.0

Source: includes/Support/redis-connect-helper.php, line 597