MCPcopy
hub / github.com/grafana/dskit / setCachedShuffledSubring

Method setCachedShuffledSubring

ring/ring.go:1329–1343  ·  view source on GitHub ↗
(identifier string, size int, subring *Ring)

Source from the content-addressed store, hash-verified

1327}
1328
1329func (r *Ring) setCachedShuffledSubring(identifier string, size int, subring *Ring) {
1330 if subring == nil || r.cfg.SubringCacheDisabled {
1331 return
1332 }
1333
1334 r.mtx.Lock()
1335 defer r.mtx.Unlock()
1336
1337 // Only cache if *this* ring hasn't changed since computing result
1338 // (which can happen between releasing the read lock and getting read-write lock).
1339 // Note that shuffledSubringCache can be only nil when set by test.
1340 if r.shuffledSubringCache != nil && r.lastTopologyChange.Equal(subring.lastTopologyChange) {
1341 r.shuffledSubringCache[subringCacheKey{identifier: identifier, shardSize: size}] = subring
1342 }
1343}
1344
1345func (r *Ring) getCachedShuffledSubringWithLookback(identifier string, size int, lookbackPeriod time.Duration, now time.Time) *Ring {
1346 if r.cfg.SubringCacheDisabled {

Callers 1

ShuffleShardMethod · 0.95

Calls 1

EqualMethod · 0.45

Tested by

no test coverage detected