(identifier string, size int, zoneStableSharding bool)
| 771 | } |
| 772 | |
| 773 | func (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 | |
| 789 | func (r *Ring) shuffleShard(identifier string, size int, lookbackPeriod time.Duration, now time.Time, zoneStableSharding bool) *Ring { |
| 790 | lookbackUntil := now.Add(-lookbackPeriod).Unix() |
no test coverage detected