mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	* 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
		
			
				
	
	
		
			21 lines
		
	
	
		
			569 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			569 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Package loadbalance is middleware for rewriting responses to do "load balancing"
 | |
| package loadbalance
 | |
| 
 | |
| import (
 | |
| 	"github.com/miekg/coredns/middleware"
 | |
| 
 | |
| 	"github.com/miekg/dns"
 | |
| 	"golang.org/x/net/context"
 | |
| )
 | |
| 
 | |
| // RoundRobin is middleware to rewrite responses for "load balancing".
 | |
| type RoundRobin struct {
 | |
| 	Next middleware.Handler
 | |
| }
 | |
| 
 | |
| // ServeDNS implements the middleware.Handler interface.
 | |
| func (rr RoundRobin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
 | |
| 	wrr := NewRoundRobinResponseWriter(w)
 | |
| 	return rr.Next.ServeDNS(ctx, wrr, r)
 | |
| }
 |