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

@@ -9,6 +9,7 @@ import (
"github.com/miekg/coredns/middleware/pkg/dnsrecorder"
"github.com/miekg/coredns/middleware/test"
"github.com/hashicorp/golang-lru"
"github.com/miekg/dns"
"golang.org/x/net/context"
)
@@ -77,7 +78,8 @@ func TestLookupZone(t *testing.T) {
dnskey, rm1, rm2 := newKey(t)
defer rm1()
defer rm2()
dh := New([]string{"miek.nl."}, []*DNSKEY{dnskey}, fm)
cache, _ := lru.New(defaultCap)
dh := New([]string{"miek.nl."}, []*DNSKEY{dnskey}, fm, cache)
ctx := context.TODO()
for _, tc := range dnsTestCases {
@@ -115,7 +117,8 @@ func TestLookupDNSKEY(t *testing.T) {
dnskey, rm1, rm2 := newKey(t)
defer rm1()
defer rm2()
dh := New([]string{"miek.nl."}, []*DNSKEY{dnskey}, test.ErrorHandler())
cache, _ := lru.New(defaultCap)
dh := New([]string{"miek.nl."}, []*DNSKEY{dnskey}, test.ErrorHandler(), cache)
ctx := context.TODO()
for _, tc := range dnssecTestCases {