changed embedded mutex to private field (#217)
Some checks failed
sync / sync (push) Failing after 16m12s
test / test (push) Failing after 17m28s
coverage / build (push) Failing after 17m40s

This commit is contained in:
2025-05-25 03:15:03 +05:00
committed by GitHub
parent 0f8f12aee0
commit 13f90ff716
13 changed files with 151 additions and 151 deletions

View File

@@ -137,7 +137,7 @@ type cache struct {
opts Options
sync.RWMutex
mu sync.RWMutex
}
type cacheEntry struct {
@@ -171,7 +171,7 @@ func (c *cache) put(req string, res string) {
ttl = c.opts.MaxCacheTTL
}
c.Lock()
c.mu.Lock()
if c.entries == nil {
c.entries = make(map[string]cacheEntry)
}
@@ -207,7 +207,7 @@ func (c *cache) put(req string, res string) {
}
c.opts.Meter.Counter(semconv.CacheItemsTotal, "type", "dns").Inc()
c.Unlock()
c.mu.Unlock()
}
func (c *cache) get(req string) (res string) {
@@ -219,8 +219,8 @@ func (c *cache) get(req string) (res string) {
return ""
}
c.RLock()
defer c.RUnlock()
c.mu.RLock()
defer c.mu.RUnlock()
if c.entries == nil {
return ""