Thread-safe general purpose auto-refresh cache that watches for updates asynchronously for the keys after they are added to the cache. An item can be inserted only once. Get reads from sync.map while refresh is invoked on a snapshot of keys. Cache eventually catches up on deleted items. Sync is ru
| 92 | // |
| 93 | // Sync is run as a fixed-interval-scheduled-task, and is skipped if sync from previous cycle is still running. |
| 94 | type autoRefreshCache struct { |
| 95 | syncCb CacheSyncItem |
| 96 | lruMap *lru.Cache |
| 97 | syncRateLimiter RateLimiter |
| 98 | resyncPeriod time.Duration |
| 99 | scope promutils.Scope |
| 100 | } |
| 101 | |
| 102 | func (w *autoRefreshCache) Start(ctx context.Context) { |
| 103 | go wait.Until(func() { w.sync(ctx) }, w.resyncPeriod, ctx.Done()) |
nothing calls this directly
no outgoing calls
no test coverage detected