NewRedisClient
Initializes a new Redis client with the given options, configures Prometheus metrics collection for Redis, and adds an instrumentation hook to the client.
def NewRedisClient(
ctx: context.Context,
cfg: RedisOptions,
secretManager: SecretManager,
scope: promutils.Scope
) - > *redis.Client, error
Initializes a new Redis client with the given options. This function sets up the client with Prometheus instrumentation for monitoring Redis operations.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used for cancellation and timeouts. |
| cfg | RedisOptions | The configuration options for the Redis client, including connection details. |
| secretManager | SecretManager | The secret manager used to retrieve sensitive information, such as Redis passwords, if required by the configuration. |
| scope | promutils.Scope | The Prometheus scope for metrics collection, used to instrument the Redis client. |
Returns
| Type | Description |
|---|---|
*redis.Client, error | A new Redis client instance and an error if the client could not be initialized. |