From 4b4d8c8abbd7cc816f751e1192643011d1fffe09 Mon Sep 17 00:00:00 2001 From: Andrew Baptist Date: Thu, 25 Jan 2024 16:26:41 -0500 Subject: [PATCH] kvclient: remove MakeEvictionToken from the interface 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 --- pkg/kv/kvclient/rangecache/range_cache.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/pkg/kv/kvclient/rangecache/range_cache.go b/pkg/kv/kvclient/rangecache/range_cache.go index 6429b90cf6c0..710fb4c52243 100644 --- a/pkg/kv/kvclient/rangecache/range_cache.go +++ b/pkg/kv/kvclient/rangecache/range_cache.go @@ -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 "" @@ -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) @@ -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 } @@ -967,7 +957,7 @@ func tryLookupImpl( } entry = &newEntry } - lookupRes = rc.makeEvictionToken(entry) + lookupRes = EvictionToken{rdc: rc, entry: entry} return lookupRes, nil }