NewInMemoryAutoRefresh
Creates a new InMemoryAutoRefresh.
def NewInMemoryAutoRefresh(
name: string,
syncCb: SyncFunc,
syncRateLimiter: workqueue.TypedRateLimiter[*Batch],
resyncPeriod: time.Duration,
parallelizm: uint,
size: uint,
scope: promutils.Scope,
options: ...Option
) - > (*InMemoryAutoRefresh, error)
Creates a new InMemoryAutoRefresh instance. This function initializes an auto-refresh mechanism that periodically synchronizes data using a provided callback function and manages a cache of items.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | A descriptive name for this InMemoryAutoRefresh instance, used for logging and metrics. |
| syncCb | SyncFunc | The callback function responsible for synchronizing data. This function will be invoked periodically to refresh the cached items. |
| syncRateLimiter | workqueue.TypedRateLimiter[*Batch] | A rate limiter to control the frequency of synchronization operations, preventing excessive calls to the sync callback. |
| resyncPeriod | time.Duration | The duration after which a full resynchronization of all items should occur, ensuring data freshness. |
| parallelizm | uint | The number of concurrent workers that can process synchronization batches, controlling the parallelism of the refresh process. |
| size | uint | The maximum number of items the underlying LRU cache can hold. When this limit is reached, the least recently used items will be evicted. |
| scope | promutils.Scope | The Prometheus metrics scope to which metrics related to this auto-refresh instance will be reported. |
| options | ...Option | Optional configuration parameters to customize the behavior of the InMemoryAutoRefresh instance, such as clock implementation or batch creation callback. |
Returns
| Type | Description |
|---|---|
(*InMemoryAutoRefresh, error) | A pointer to the newly created InMemoryAutoRefresh instance and an error if the LRU cache creation fails. |