@ Nullable public DnsQueryCacheResult tryToResolve ( DnsQuery query ) { CachedDnsQueryResult cachedResult = cache . get ( query ) ; if ( cachedResult == null ) { logger . trace ( "{} cache miss" , query ) ; return null ; } DnsResponse result = cachedResult . response ; assert result != null ; // results with null responses should never be in cache map if ( result . isSuccessful ( ) ) { logger . trace ( "{} cache hit" , query ) ; } else { logger . trace ( "{} error cache hit" , query ) ; } if ( isExpired ( cachedResult ) ) { logger . trace ( "{} hard TTL expired" , query ) ; return null ; } else if ( isSoftExpired ( cachedResult ) ) { logger . trace ( "{} soft TTL expired" , query ) ; return new DnsQueryCacheResult ( result , true ) ; } return new DnsQueryCacheResult ( result , false ) ; }
Tries to get status of the entry for some query from the cache .