Skip to content

Commit

Permalink
kvclient: remove MakeEvictionToken from the interface
Browse files Browse the repository at this point in the history
This method was only used internally and is simple to create manually
now. It was confusing to have it on the public interface as its not the
right way to create a token.

Epic: none

Release note: None
  • Loading branch information
andrewbaptist committed Jan 26, 2024
1 parent 0a14ee7 commit 4b4d8c8
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions pkg/kv/kvclient/rangecache/range_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,6 @@ type EvictionToken struct {
entry *cacheEntry
}

func (rc *RangeCache) makeEvictionToken(entry *cacheEntry) EvictionToken {
return EvictionToken{
rdc: rc,
entry: entry,
}
}

// MakeEvictionToken is the exported ctor. For tests only.
func (rc *RangeCache) MakeEvictionToken(entry *cacheEntry) EvictionToken {
return rc.makeEvictionToken(entry)
}

func (et EvictionToken) String() string {
if !et.Valid() {
return "<empty>"
Expand Down Expand Up @@ -622,7 +610,9 @@ func (rc *RangeCache) Lookup(ctx context.Context, key roachpb.RKey) (roachpb.Ran

// GetCachedOverlapping returns all the cached entries which overlap a given
// span [Key, EndKey). The results are sorted ascendingly.
func (rc *RangeCache) GetCachedOverlapping(ctx context.Context, span roachpb.RSpan) []roachpb.RangeInfo {
func (rc *RangeCache) GetCachedOverlapping(
ctx context.Context, span roachpb.RSpan,
) []roachpb.RangeInfo {
rc.rangeCache.RLock()
defer rc.rangeCache.RUnlock()
rawEntries := rc.getCachedOverlappingRLocked(ctx, span)
Expand Down Expand Up @@ -711,7 +701,7 @@ func (rc *RangeCache) tryLookup(
rc.rangeCache.RLock()
if entry, _ := rc.getCachedRLocked(ctx, key, useReverseScan); entry != nil {
rc.rangeCache.RUnlock()
returnToken := rc.makeEvictionToken(entry)
returnToken := EvictionToken{rdc: rc, entry: entry}
return returnToken, nil
}

Expand Down Expand Up @@ -967,7 +957,7 @@ func tryLookupImpl(
}
entry = &newEntry
}
lookupRes = rc.makeEvictionToken(entry)
lookupRes = EvictionToken{rdc: rc, entry: entry}
return lookupRes, nil
}

Expand Down

0 comments on commit 4b4d8c8

Please sign in to comment.