Skip to main content

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

NameTypeDescription
ctxcontext.ContextThe context for the operation, used for cancellation and timeouts.
cfgRedisOptionsThe configuration options for the Redis client, including connection details.
secretManagerSecretManagerThe secret manager used to retrieve sensitive information, such as Redis passwords, if required by the configuration.
scopepromutils.ScopeThe Prometheus scope for metrics collection, used to instrument the Redis client.

Returns

TypeDescription
*redis.Client, errorA new Redis client instance and an error if the client could not be initialized.