MCPcopy Create free account
hub / github.com/cortexproject/cortex / setCachedShuffledSubring

Method setCachedShuffledSubring

pkg/ring/ring.go:974–988  ·  view source on GitHub ↗
(identifier string, size int, zoneStableSharding bool, subring *Ring)

Source from the content-addressed store, hash-verified

972}
973
974func (r *Ring) setCachedShuffledSubring(identifier string, size int, zoneStableSharding bool, subring *Ring) {
975 if subring == nil || r.cfg.SubringCacheDisabled {
976 return
977 }
978
979 r.mtx.Lock()
980 defer r.mtx.Unlock()
981
982 // Only cache if *this* ring hasn't changed since computing result
983 // (which can happen between releasing the read lock and getting read-write lock).
984 // Note that shuffledSubringCache can be only nil when set by test.
985 if r.shuffledSubringCache != nil && r.lastTopologyChange.Equal(subring.lastTopologyChange) {
986 r.shuffledSubringCache[subringCacheKey{identifier: identifier, shardSize: size, zoneStableSharding: zoneStableSharding}] = subring
987 }
988}
989
990func (r *Ring) CleanupShuffleShardCache(identifier string) {
991 if r.cfg.SubringCacheDisabled {

Callers 1

shuffleShardWithCacheMethod · 0.95

Calls 1

EqualMethod · 0.65

Tested by

no test coverage detected