code: func (i *itemWithExp) randomlyExpired(ctx context.Context, now time.Time, threshold time.Duration) bool {
  	if i.exp.IsZero() {
  		return false // never expires
  	}
  
  	ttl := i.exp.Sub(now)
  	if ttl > threshold {
  		return false // far from expiration, no need to enable randomization
  	}
  
  	// TODO(vadimsh): The choice of distribution here was made arbitrary. Some
  	// literature suggests to use exponential distribution instead, but it's not
  	// clear how to pick parameters for it. In practice what we do here seems good
  	// enough. On each check we randomly expire the item with probability
  	// p = (threshold - ttl) / threshold. Closer the item to its true expiration
  	// (ttl is smaller), higher the probability.
  	rnd := time.Duration(mathrand.Int63n(ctx, int64(threshold)))
  	return rnd > ttl
  }
docs: // randomlyExpired returns true if the item must be considered already expired.
  //
  // See WithRandomizedExpiration for the rationale. The context is used only to
  // grab RNG.