NewFactory
Initializes a new cache factory that should be used whenever typed caches are created.
def NewFactory(
ctx: context.Context,
c: *Config,
secretManager: SecretManager,
scope: promutils.Scope
) - > Factory, error
Initializes a new cache factory that should be used whenever typed caches are created. This function sets up either an in-memory fixed-size cache or a Redis-backed cache based on the provided configuration.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for the operation, used for managing cancellation and deadlines, particularly when creating a Redis client. |
| c | *Config | The configuration object specifying the cache type (in-memory or Redis) and its settings, such as size, expiration, and Redis options. |
| secretManager | SecretManager | The secret manager used to retrieve sensitive information, such as Redis connection details, if a Redis cache is configured. |
| scope | promutils.Scope | The Prometheus metrics scope used for reporting metrics related to the cache operations, particularly for the Redis client. |
Returns
| Type | Description |
|---|---|
Factory, error | A new Factory instance configured with the specified cache type, or an error if Redis client creation fails. |