@UnstableApi
    public DnsResolverGroupBuilder autoRefreshTimeout(ToLongFunction<? super String> timeoutFunction) {
        requireNonNull(timeoutFunction, "timeoutFunction");
        //noinspection unchecked
        autoRefreshTimeoutFunction = (ToLongFunction<String>) timeoutFunction;
        return this;
    }
Sets the {@link ToLongFunction} which determines how long the {@link DnsRecord}s for a hostname should
be refreshed after the first cache. The {@link ToLongFunction} should return the refresh timeout in
milliseconds. If a non-positive number is returned, the {@link DnsRecord}s are removed immediately
without refresh.

<p>Note that the timeout function is called whenever the cached {@link DnsRecord}s expire.

<p>For example:
<pre>{@code
AtomicInteger refreshCounter = new AtomicInteger(MAX_NUM_REFRESH);
dnsResolverGroupBuilder.autoRefreshTimeout(hostname -> {
    if (hostname.endsWith("busy.domain.com")) {
        return Duration.ofDays(7).toMillis(); // Automatically refresh the cached domain for 7 days.
    }
    if (hostname.endsWith("sporadic.domain.dom")) {
        return 0; // Don't need to refresh a sporadically used domain.
    }

    if (hostname.endsWith("counting.domain.dom")) {
        // Allow refreshing up to MAX_NUM_REFRESH times.
        if (refreshCounter.getAndDecrease() > 0) {
            return Long.MAX_VALUE;
        } else {
            refreshCounter.set(MAX_NUM_REFRESH);
            return 0;
        }
    }
    ...
});
}</pre>
core/src/main/java/com/linecorp/armeria/client/DnsResolverGroupBuilder.java