Skip to main content

NewAutoRefreshCache

Instantiates a new AutoRefresh Cache that syncs items periodically.

def NewAutoRefreshCache(
name: string,
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 periodically.

Parameters

NameTypeDescription
namestringThe name of the cache, used for identification and metrics.
syncCbSyncFuncThe callback function to be executed when items need to be synchronized.
syncRateLimiterworkqueue.TypedRateLimiter[*Batch]The rate limiter to control the frequency of synchronization operations.
resyncPeriodtime.DurationThe duration after which the cache will automatically resynchronize its items.
parallelizmuintThe number of concurrent synchronization operations allowed.
sizeuintThe maximum number of items the cache can hold.
scopepromutils.ScopeThe Prometheus scope for metrics collection related to the cache.

Returns

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