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

@@ -6,6 +6,7 @@ import (
"github.com/miekg/coredns/core/dnsserver"
"github.com/miekg/coredns/middleware"
"github.com/hashicorp/golang-lru"
"github.com/mholt/caddy"
)
@@ -22,8 +23,12 @@ func setup(c *caddy.Controller) error {
return middleware.Error("dnssec", err)
}
cache, err := lru.New(defaultCap)
if err != nil {
return err
}
dnsserver.GetConfig(c).AddMiddleware(func(next middleware.Handler) middleware.Handler {
return New(zones, keys, next)
return New(zones, keys, next, cache)
})
return nil