@@ -125,16 +125,15 @@ type IndexedClient struct {
125125 LastFlush atomicx.Time `msg:"LastFlush,extension"`
126126
127127 // internal index configuration
128- name string `msg:"-"`
129- cacheProvider string `msg:"-"`
130- options atomic.Value `msg:"-"`
131- ico IndexedClientOptions `msg:"-"`
132- lastWrite atomicx.Time `msg:"-"`
133- isClosing atomic.Bool
134- cancel context.CancelFunc
135- flusherExited atomic.Bool
136- reaperExited atomic.Bool
137- reapInProgress atomic.Bool
128+ name string `msg:"-"`
129+ cacheProvider string `msg:"-"`
130+ options atomic.Value `msg:"-"`
131+ ico IndexedClientOptions `msg:"-"`
132+ lastWrite atomicx.Time `msg:"-"`
133+ isClosing atomic.Bool
134+ cancel context.CancelFunc
135+ flusherExited atomic.Bool
136+ reaperExited atomic.Bool
138137
139138 // used only in tests: fields to interact with client goroutines
140139 forceFlush chan bool
@@ -185,23 +184,6 @@ func (idx *IndexedClient) updateIndex(cacheKey string, size int64, la, lw, e tim
185184 metrics .ObserveCacheSizeChange (idx .name , idx .cacheProvider , cacheSize , count )
186185 idx .lastWrite .Store (time .Now ())
187186 idx .Objects .Store (cacheKey , obj )
188-
189- // Inline eviction guard: trigger async reaping if approaching max size
190- // to prevent large overshoot between periodic reaper cycles.
191- // Only trigger if reaper goroutine is running (ReapInterval > 0) and
192- // no reap is already in progress.
193- opts := idx .options .Load ().(* options.Options )
194- if opts .ReapInterval > 0 && opts .MaxSizeBytes > 0 && cacheSize > 0 && ! idx .reapInProgress .Load () {
195- threshold := int64 (float64 (opts .MaxSizeBytes ) * 0.9 ) // 90% threshold
196- if cacheSize > threshold {
197- select {
198- case idx .forceReap <- true :
199- // successfully triggered async reap
200- default :
201- // reap already in progress or channel full, skip
202- }
203- }
204- }
205187}
206188
207189func (idx * IndexedClient ) StoreReference (cacheKey string , data cache.ReferenceObject , ttl time.Duration ) error {
@@ -425,12 +407,6 @@ REAPER:
425407// reap makes a single iteration through the cache index to to find and remove expired elements
426408// and evict least-recently-accessed elements to maintain the Maximum allowed Cache Size
427409func (idx * IndexedClient ) reap () {
428- // Set flag to prevent concurrent reaps
429- if ! idx .reapInProgress .CompareAndSwap (false , true ) {
430- return // reap already in progress, skip
431- }
432- defer idx .reapInProgress .Store (false )
433-
434410 cacheSize := max (atomic .LoadInt64 (& idx .CacheSize ), 0 )
435411 removals := make ([]string , 0 )
436412 remainders := make (objectsAtime , 0 , cacheSize )
0 commit comments