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, which is a cache that automatically refreshes its items based on a provided synchronization callback and resynchronization period. This function is used to initialize a cache that can manage and refresh data with rate limiting and optional Prometheus metrics for evictions.
Parameters
| Name | Type | Description |
|---|---|---|
| syncCb | CacheSyncItem | The callback function used to synchronize items within the cache. This function defines how individual cache items are refreshed. |
| syncRateLimiter | RateLimiter | The rate limiter to control the frequency of synchronization operations, preventing excessive calls to the sync callback. |
| resyncPeriod | time.Duration | The duration after which the cache should attempt to resynchronize its items, ensuring data freshness. |
| size | int | The maximum number of items the cache can hold. When this limit is exceeded, the least recently used items will be evicted. |
| scope | promutils.Scope | An optional Prometheus scope for metrics. If provided, a counter for LRU evictions will be created and incremented when items are removed from the cache. |
Returns
| Type | Description |
|---|---|
AutoRefreshCache, error | A new AutoRefreshCache instance if successful, otherwise an error. |