Replace go-cache with golang-lru in dnssec (#336)

* Replace go-cache with golang-lru

This fix replace go-cache with golang-lru, as is specified in 335.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

* Move cache initialization to setup

This commit move cache initialization to setup in dnssec middleware.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang
2016-10-17 05:04:36 -07:00
committed by Miek Gieben
parent 03bc071774
commit 58387afd5d
5 changed files with 27 additions and 16 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/miekg/coredns/middleware/test"
"github.com/miekg/coredns/request"
"github.com/hashicorp/golang-lru"
"github.com/miekg/dns"
)
@@ -68,7 +69,8 @@ func TestSigningDifferentZone(t *testing.T) {
m := testMsgEx()
state := request.Request{Req: m}
d := New([]string{"example.org."}, []*DNSKEY{key}, nil)
cache, _ := lru.New(defaultCap)
d := New([]string{"example.org."}, []*DNSKEY{key}, nil, cache)
m = d.Sign(state, "example.org.", time.Now().UTC())
if !section(m.Answer, 1) {
t.Errorf("answer section should have 1 sig")
@@ -157,7 +159,8 @@ func testDelegationMsg() *dns.Msg {
func newDnssec(t *testing.T, zones []string) (Dnssec, func(), func()) {
k, rm1, rm2 := newKey(t)
d := New(zones, []*DNSKEY{k}, nil)
cache, _ := lru.New(defaultCap)
d := New(zones, []*DNSKEY{k}, nil, cache)
return d, rm1, rm2
}