Skip to main content

NewAutoRefreshCache

No overview available.

def NewAutoRefreshCache(
syncCb: CacheSyncItem,
syncRateLimiter: RateLimiter,
resyncPeriod: time.Duration,
size: int,
scope: promutils.Scope
) - > AutoRefreshCache, error

Deprecated: This utility is deprecated, it has been refactored and moved into cache package. Creates a new AutoRefreshCache instance. This function initializes a cache that automatically refreshes its items based on a provided synchronization callback and rate limiter.

Parameters

NameTypeDescription
syncCbCacheSyncItemThe callback function used to synchronize items within the cache.
syncRateLimiterRateLimiterThe rate limiter to control the frequency of synchronization operations.
resyncPeriodtime.DurationThe duration after which the cache should attempt to resynchronize its items.
sizeintThe maximum number of items the cache can hold before evicting older items.
scopepromutils.ScopeThe Prometheus scope used for metrics, specifically to log evictions from the LRU cache. Can be nil if metrics are not required.

Returns

TypeDescription
AutoRefreshCache, errorA new AutoRefreshCache instance and an error if the cache could not be created.