Cache (#126)
* Add middleware/cache Add a caching middleware that caches nxdomain, nodata and successful responses. It differentiates between DNSSEC on normal DNS replies. Each reply is compress and scrubbed so it will fit the specific client asking for it. * first simple test, less exporting of stuff * more * Add middleware/cache Add a caching middleware that caches nxdomain, nodata and successful responses. It differentiates between DNSSEC on normal DNS replies. Each reply is compressed and scrubbed so it will fit the specific client asking for it. The TTL is decremented with the time spend in the cache. There is syntax that allows you to cap the TTL for all records, no matter what. This allows for a shortlived cache, just to absorb query peaks. +Tests * cache test infrastructure * Testing
This commit is contained in:
parent
4e3c82bec5
commit
10db2a80df
12 changed files with 566 additions and 12 deletions
25
middleware/cache/item_test.go
vendored
Normal file
25
middleware/cache/item_test.go
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
func TestKey(t *testing.T) {
|
||||
if noDataKey("miek.nl.", dns.TypeMX, false) != "0miek.nl...15" {
|
||||
t.Errorf("failed to create correct key")
|
||||
}
|
||||
if noDataKey("miek.nl.", dns.TypeMX, true) != "1miek.nl...15" {
|
||||
t.Errorf("failed to create correct key")
|
||||
}
|
||||
if nameErrorKey("miek.nl.", false) != "0miek.nl." {
|
||||
t.Errorf("failed to create correct key")
|
||||
}
|
||||
if nameErrorKey("miek.nl.", true) != "1miek.nl." {
|
||||
t.Errorf("failed to create correct key")
|
||||
}
|
||||
if noDataKey("miek.nl.", dns.TypeMX, false) != successKey("miek.nl.", dns.TypeMX, false) {
|
||||
t.Errorf("nameErrorKey and successKey should be the same")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue