Skip to main content

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

NameTypeDescription
namestringA descriptive name for this InMemoryAutoRefresh instance, used for identification and metrics.
syncCbSyncFuncThe callback function responsible for performing the actual data synchronization logic.
syncRateLimiterworkqueue.TypedRateLimiter[*Batch]A rate limiter to control the frequency of synchronization operations, preventing excessive resource usage.
resyncPeriodtime.DurationThe duration after which a full resynchronization of data should occur.
parallelizmuintThe number of concurrent workers or goroutines that can process synchronization batches in parallel.
sizeuintThe maximum number of items the underlying LRU cache can hold before evicting the least recently used items.
scopepromutils.ScopeThe Prometheus metrics scope to which metrics related to this auto-refresh instance will be reported.
options...OptionOptional configuration parameters to customize the behavior of the InMemoryAutoRefresh instance.

Returns

TypeDescription
(*InMemoryAutoRefresh, error)A pointer to the newly created InMemoryAutoRefresh instance and an error if the LRU cache creation fails.