mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 09:43:17 -04:00 
			
		
		
		
	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
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			504 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			504 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package cache
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/miekg/dns"
 | |
| )
 | |
| 
 | |
| func TestKey(t *testing.T) {
 | |
| 	if x := rawKey("miek.nl.", dns.TypeMX, false); x != "0miek.nl..15" {
 | |
| 		t.Errorf("failed to create correct key, got %s", x)
 | |
| 	}
 | |
| 	if x := rawKey("miek.nl.", dns.TypeMX, true); x != "1miek.nl..15" {
 | |
| 		t.Errorf("failed to create correct key, got %s", x)
 | |
| 	}
 | |
| 	// 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)
 | |
| 	}
 | |
| }
 |