middleware/cache: split cache in positive and negative and use lru (#298)

Make the cache memory bounded, by using a LRU cache. Also split the
cache in a positive and negative one - each with its own controls.

Extend the cache stanza to allow for this:

    cache {
       positive limit [ttl]
       negative limit [ttl]
    }

is now possible. This also add a cache_test.go in the toplevel test/
directory that exercises the caching path.

Fixes #260
This commit is contained in:
Miek Gieben 2016-10-02 08:31:44 +01:00 committed by GitHub
parent 9b6b8d2762
commit e54c232c8c
16 changed files with 413 additions and 190 deletions

View file

@ -14,7 +14,7 @@ func TestProxyToChaosServer(t *testing.T) {
`
chaos, err := CoreDNSServer(corefile)
if err != nil {
t.Fatalf("could not get CoreDNS serving instance: %s", err)
t.Fatalf("Could not get CoreDNS serving instance: %s", err)
}
udpChaos, _ := CoreDNSServerPorts(chaos, 0)
@ -26,7 +26,7 @@ func TestProxyToChaosServer(t *testing.T) {
`
proxy, err := CoreDNSServer(corefileProxy)
if err != nil {
t.Fatalf("could not get CoreDNS serving instance")
t.Fatalf("Could not get CoreDNS serving instance")
}
udp, _ := CoreDNSServerPorts(proxy, 0)