private void assignMinimumTTL ( List < ? extends DnsAnswer > dnsAnswers , LookupResult . Builder builder ) { if ( config . hasOverrideTTL ( ) ) { builder . cacheTTL ( config . getCacheTTLOverrideMillis ( ) ) ; } else { // Deduce minimum TTL on all TXT records. A TTL will always be returned by DNS server. builder . cacheTTL ( dnsAnswers . stream ( ) . map ( DnsAnswer :: dnsTTL ) . min ( Comparator . comparing ( Long :: valueOf ) ) . get ( ) * 1000 ) ; } }
Assigns the minimum TTL found in the supplied DnsAnswers . The minimum makes sense because this is the least amount of time that at least one of the records is valid for .