Skip to content

Commit

Permalink
Restore ring caching optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
jhalterman committed Aug 6, 2024
1 parent 9fde251 commit d6fe0e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ring/ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,11 @@ func (r *Ring) ShuffleShard(identifier string, size int) ReadRing {
// This function supports caching, but the cache will only be effective if successive calls for the
// same identifier are with the same lookbackPeriod and increasing values of now.
func (r *Ring) ShuffleShardWithLookback(identifier string, size int, lookbackPeriod time.Duration, now time.Time) ReadRing {
// Nothing to do if the shard size is not smaller than the actual ring.
if lookbackPeriod > 0 && (size <= 0 || r.InstancesCount() <= size) {
return r
}

if cached := r.getCachedShuffledSubringWithLookback(identifier, size, lookbackPeriod, now); cached != nil {
return cached
}
Expand Down

0 comments on commit d6fe0e1

Please sign in to comment.