Class InetAddressCacheUtilCommons


  • public class InetAddressCacheUtilCommons
    extends Object
    Util class to manipulate dns cache.
    Since:
    1.6.0
    Author:
    Jerry Lee (oldratlee at gmail dot com)
    • Field Detail

      • NEVER_EXPIRATION

        public static final long NEVER_EXPIRATION
        We never really have "never".

        Long.MAX_VALUE(~9e18) nanoseconds is ~292 years.

        Long.MAX_VALUE / 1e9 / 3600 / 24 / 365 ~= 292.47.

        See Also:
        Constant Field Values
    • Constructor Detail

      • InetAddressCacheUtilCommons

        public InetAddressCacheUtilCommons()
    • Method Detail

      • setDnsCachePolicy

        public static void setDnsCachePolicy​(int cacheSeconds)
                                      throws NoSuchFieldException,
                                             IllegalAccessException
        Set JVM DNS cache policy
        Parameters:
        cacheSeconds - set default dns cache time. Special input case:
        • -1 means never expired.(In effect, all negative value)
        • 0 never cached.
        Throws:
        NoSuchFieldException
        IllegalAccessException
        See Also:
        InetAddressCachePolicy, InetAddressCachePolicy.cachePolicy
      • getDnsCachePolicy

        public static int getDnsCachePolicy()
      • setDnsNegativeCachePolicy

        public static void setDnsNegativeCachePolicy​(int negativeCacheSeconds)
                                              throws NoSuchFieldException,
                                                     IllegalAccessException
        Set JVM DNS negative cache policy
        Parameters:
        negativeCacheSeconds - set default dns cache time. Special input case:
        • -1 means never expired.(In effect, all negative value)
        • 0 never cached.
        Throws:
        NoSuchFieldException
        IllegalAccessException
        See Also:
        InetAddressCachePolicy, InetAddressCachePolicy.negativeCachePolicy
      • getDnsNegativeCachePolicy

        public static int getDnsNegativeCachePolicy()