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 a specified size.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | A descriptive name for this InMemoryAutoRefresh instance, used for identification and metrics. |
| syncCb | SyncFunc | The callback function responsible for performing the actual data synchronization logic. |
| syncRateLimiter | workqueue.TypedRateLimiter[*Batch] | A rate limiter to control the frequency of synchronization operations, preventing excessive resource usage. |
| resyncPeriod | time.Duration | The duration after which a full resynchronization of data should occur. |
| parallelizm | uint | The number of concurrent workers or goroutines that can process synchronization batches in parallel. |
| size | uint | The maximum number of items the underlying LRU cache can hold before evicting the least recently used items. |
| 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. |
Returns
| Type | Description |
|---|---|
(*InMemoryAutoRefresh, error) | A pointer to the newly created InMemoryAutoRefresh instance and an error if the LRU cache creation fails. |