Skip to main content

NewAutoRefreshBatchedCache

Instantiates a new AutoRefresh Cache that syncs items in batches.

def NewAutoRefreshBatchedCache(
name: string,
createBatches: CreateBatchesFunc,
syncCb: SyncFunc,
syncRateLimiter: workqueue.TypedRateLimiter[*Batch],
resyncPeriod: time.Duration,
parallelizm: uint,
size: uint,
scope: promutils.Scope
) - > AutoRefresh, error

Instantiates a new AutoRefresh Cache that syncs items in batches.

Parameters

NameTypeDescription
namestringThe name of the cache, used for identification and metrics.
createBatchesCreateBatchesFuncA function that defines how items are grouped into batches for synchronization.
syncCbSyncFuncThe callback function executed to synchronize a batch of items.
syncRateLimiterworkqueue.TypedRateLimiter[*Batch]A rate limiter to control the frequency of synchronization operations for batches.
resyncPeriodtime.DurationThe duration after which the cache will perform a full resynchronization of all items.
parallelizmuintThe number of concurrent synchronization operations that can run in parallel.
sizeuintThe maximum number of items the cache can hold.
scopepromutils.ScopeThe Prometheus metrics scope for reporting cache-related metrics.

Returns

TypeDescription
AutoRefresh, errorA new AutoRefresh instance and an error if the instantiation fails.