mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 08:44:17 -04:00
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:
19
middleware/cache/item_test.go
vendored
19
middleware/cache/item_test.go
vendored
@@ -7,19 +7,14 @@ import (
|
||||
)
|
||||
|
||||
func TestKey(t *testing.T) {
|
||||
if noDataKey("miek.nl.", dns.TypeMX, false) != "0miek.nl...15" {
|
||||
t.Errorf("failed to create correct key")
|
||||
if x := rawKey("miek.nl.", dns.TypeMX, false); x != "0miek.nl..15" {
|
||||
t.Errorf("failed to create correct key, got %s", x)
|
||||
}
|
||||
if noDataKey("miek.nl.", dns.TypeMX, true) != "1miek.nl...15" {
|
||||
t.Errorf("failed to create correct key")
|
||||
if x := rawKey("miek.nl.", dns.TypeMX, true); x != "1miek.nl..15" {
|
||||
t.Errorf("failed to create correct key, got %s", x)
|
||||
}
|
||||
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")
|
||||
// rawKey does not lowercase.
|
||||
if x := rawKey("miEK.nL.", dns.TypeMX, true); x != "1miEK.nL..15" {
|
||||
t.Errorf("failed to create correct key, got %s", x)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user