MCPcopy
hub / github.com/flyteorg/flyte / InMemoryAutoRefresh

Struct InMemoryAutoRefresh

flytestdlib/cache/in_memory_auto_refresh.go:98–117  ·  view source on GitHub ↗

InMemoryAutoRefresh is an in-memory implementation of the AutoRefresh interface. It is a 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

Source from the content-addressed store, hash-verified

96//
97// Sync is run as a fixed-interval-scheduled-task, and is skipped if sync from previous cycle is still running.
98type InMemoryAutoRefresh struct {
99 name string
100 metrics metrics
101 syncCb SyncFunc
102 createBatchesCb CreateBatchesFunc
103 lruMap *lru.Cache
104 // Items that are currently being processed are in the processing set.
105 // It will prevent the same item from being processed multiple times by different workers.
106 processing *sync.Map
107 toDelete *syncSet
108 syncPeriod time.Duration
109 workqueue workqueue.TypedRateLimitingInterface[*Batch]
110 parallelizm uint
111 lock sync.RWMutex
112 clock clock.Clock // pluggable clock for unit testing
113 syncCount atomic.Int32 // internal sync counter for unit testing
114 enqueueCount atomic.Int32 // internal enqueue counter for unit testing
115 enqueueLoopRunning atomic.Bool // internal bool to ensure goroutines are running
116 syncOnCreate bool
117}
118
119// NewInMemoryAutoRefresh creates a new InMemoryAutoRefresh
120func NewInMemoryAutoRefresh(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected