From 516f9e85fe6cb5a4d7666ec18eec653e28055bff Mon Sep 17 00:00:00 2001 From: Virgil Date: Fri, 3 Apr 2026 22:45:45 +0000 Subject: [PATCH] Clarify reverse index naming --- service.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/service.go b/service.go index 91059ce..88ad6ba 100644 --- a/service.go +++ b/service.go @@ -58,11 +58,11 @@ type ReverseLookupResult struct { // index := buildReverseIndex(records, 15*time.Second) // names, ok := index.Lookup("10.10.10.10") type ReverseIndex struct { - cache *cache.Cache + lookupCache *cache.Cache } func (index *ReverseIndex) Lookup(ip string) ([]string, bool) { - if index == nil || index.cache == nil { + if index == nil || index.lookupCache == nil { return nil, false } @@ -71,7 +71,7 @@ func (index *ReverseIndex) Lookup(ip string) ([]string, bool) { return nil, false } - rawNames, found := index.cache.Get(normalizedIP) + rawNames, found := index.lookupCache.Get(normalizedIP) if !found { return nil, false } @@ -989,11 +989,11 @@ func buildReverseIndex(records map[string]NameRecords, ttl time.Duration) *Rever if ttl > 0 { cacheTTL = ttl } - reverseIndexCache := cache.New(cacheTTL, cacheTTL) + lookupCache := cache.New(cacheTTL, cacheTTL) for ip, names := range reverseIndex { - reverseIndexCache.Set(ip, names, cacheTTL) + lookupCache.Set(ip, names, cacheTTL) } - return &ReverseIndex{cache: reverseIndexCache} + return &ReverseIndex{lookupCache: lookupCache} } func normalizeIP(ip string) string { -- 2.45.3