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

Method shuffleShardWithCache

pkg/ring/ring.go:773–787  ·  view source on GitHub ↗
(identifier string, size int, zoneStableSharding bool)

Source from the content-addressed store, hash-verified

771}
772
773func (r *Ring) shuffleShardWithCache(identifier string, size int, zoneStableSharding bool) ReadRing {
774 // Nothing to do if the shard size is not smaller than the actual ring.
775 if size <= 0 || r.InstancesCount() <= size {
776 return r
777 }
778
779 if cached := r.getCachedShuffledSubring(identifier, size, zoneStableSharding); cached != nil {
780 return cached
781 }
782
783 result := r.shuffleShard(identifier, size, 0, time.Now(), zoneStableSharding)
784
785 r.setCachedShuffledSubring(identifier, size, zoneStableSharding, result)
786 return result
787}
788
789func (r *Ring) shuffleShard(identifier string, size int, lookbackPeriod time.Duration, now time.Time, zoneStableSharding bool) *Ring {
790 lookbackUntil := now.Add(-lookbackPeriod).Unix()

Callers 2

ShuffleShardMethod · 0.95

Calls 4

InstancesCountMethod · 0.95
shuffleShardMethod · 0.95

Tested by

no test coverage detected