refactor(cache): modernize with generics (#7842)

This commit is contained in:
vflaux
2026-02-04 02:23:53 +01:00
committed by GitHub
parent 923a8b5d2b
commit 30c20b52ff
13 changed files with 70 additions and 68 deletions

View File

@@ -7,6 +7,8 @@ import (
"github.com/coredns/coredns/plugin/pkg/cache"
"github.com/coredns/coredns/plugin/test"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
)
func TestCacheSet(t *testing.T) {
@@ -20,7 +22,7 @@ func TestCacheSet(t *testing.T) {
t.Fatalf("Failed to parse key: %v\n", err)
}
c := cache.New(defaultCap)
c := cache.New[[]dns.RR](defaultCap)
m := testMsg()
state := request.Request{Req: m, Zone: "miek.nl."}
k := hash(m.Answer) // calculate *before* we add the sig
@@ -44,7 +46,7 @@ func TestCacheNotValidExpired(t *testing.T) {
t.Fatalf("Failed to parse key: %v\n", err)
}
c := cache.New(defaultCap)
c := cache.New[[]dns.RR](defaultCap)
m := testMsg()
state := request.Request{Req: m, Zone: "miek.nl."}
k := hash(m.Answer) // calculate *before* we add the sig
@@ -68,7 +70,7 @@ func TestCacheNotValidYet(t *testing.T) {
t.Fatalf("Failed to parse key: %v\n", err)
}
c := cache.New(defaultCap)
c := cache.New[[]dns.RR](defaultCap)
m := testMsg()
state := request.Request{Req: m, Zone: "miek.nl."}
k := hash(m.Answer) // calculate *before* we add the sig