mirror of
https://github.com/coredns/coredns.git
synced 2026-04-05 19:55:32 -04:00
Add an atomic.Bool to singleflight prefetching (#7963)
Also updated plugin to document single-flighting Signed-off-by: Ryan Brewster <rpb@anthropic.com>
This commit is contained in:
9
plugin/cache/item.go
vendored
9
plugin/cache/item.go
vendored
@@ -2,6 +2,7 @@ package cache
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/coredns/coredns/plugin/cache/freq"
|
||||
@@ -25,6 +26,14 @@ type item struct {
|
||||
stored time.Time
|
||||
|
||||
*freq.Freq
|
||||
|
||||
// refreshing is set via CAS when a prefetch goroutine is dispatched for
|
||||
// this item and cleared when it returns, bounding in-flight prefetches
|
||||
// per item to one. A successful prefetch replaces this item in the cache
|
||||
// with a new one (zero-valued refreshing); the deferred clear matters
|
||||
// only when the prefetch fails and this item remains cached, so the next
|
||||
// hit can retry.
|
||||
refreshing atomic.Bool
|
||||
}
|
||||
|
||||
func newItem(m *dns.Msg, now time.Time, d time.Duration) *item {
|
||||
|
||||
Reference in New Issue
Block a user