func cacheDuration(rr []dns.RR, max time.Duration, empty time.Duration) time.Duration {
	if len(rr) == 0 {
		if max < empty {
			return max
		}
		return empty
	}
	ttl := rr[0].Header().Ttl
	for i := 1; i < len(rr); i++ {
		hdr := rr[i].Header()
		if hdr.Ttl < ttl {
			ttl = hdr.Ttl
		}
	}
	duration := time.Second * time.Duration(ttl)
	if duration > max {
		return max
	}
	return duration
}
// cacheDuration determines how long an entry should be cached
cacheDuration determines how long an entry should be cached
// cacheDuration determines how long an entry should be cached
func cacheDuration(rr []dns.RR, max time.Duration, empty time.Duration) time.Duration {
	if len(rr) == 0 {
		if max < empty {
			return max
		}
		return empty
	}
	ttl := rr[0].Header().Ttl
	for i := 1; i < len(rr); i++ {
		hdr := rr[i].Header()
		if hdr.Ttl < ttl {
			ttl = hdr.Ttl
		}
	}
	duration := time.Second * time.Duration(ttl)
	if duration > max {
		return max
	}
	return duration
}
func cacheDuration ( rr [ ] dns . RR , max time . Duration , empty time . Duration ) time . Duration { if len ( rr ) == 0 { if max < empty { return max } return empty } ttl := rr [ 0 ] . Header ( ) . Ttl for i := 1 ; i < len ( rr ) ; i ++ { hdr := rr [ i ] . Header ( ) if hdr . Ttl < ttl { ttl = hdr . Ttl } } duration := time . Second * time . Duration ( ttl ) if duration > max { return max } return duration }
cacheDuration determines how long an entry should be cached
cacheDuration determines how long an entry should be cached