Java JVM是否因为networkaddress.cache.ttl设置而缓存url?

Java JVM是否因为networkaddress.cache.ttl设置而缓存url?,java,dns,jvm,Java,Dns,Jvm,Oracle的文档说明了以下关于缓存ttl的内容- networkaddress.cache.ttl Specified in java.security to indicate the caching policy for successful name lookups from the name service.. The value is specified as integer to indicate the number of seconds to cache the succ

Oracle的文档说明了以下关于缓存ttl的内容-

networkaddress.cache.ttl
    Specified in java.security to indicate the caching policy for successful name lookups from the name service.. The value is specified as integer to indicate the number of seconds to cache the successful lookup.
此设置如何影响解析DNS的方式?我在geo负载均衡器后面有两个节点,我为服务连接到它们。现在,如果它们切换到指向其他两个节点,并且如果上述设置设置设置为-1,它是否仍会尝试指向先前解析的DNS并尝试转到可能不再存在的节点?如果在这种情况下不使用安全管理器,此设置是否有任何价值


提前感谢。

如果安装了安全管理器,JVM的默认行为是永久缓存(设置为-1)。因此,必须显式设置ttl超时,以便重新尝试DNS解析。您可以在应用程序启动(应用程序级)或系统级通过security manager设置此属性

java.security.Security.setProperty("networkaddress.cache.ttl" , "10");
对于系统范围,请编辑以下文件,将ttl设置为零

/jre/lib/security/java.security

networkaddress.cache.ttl=0
没有安全管理器: 通常默认值取决于操作系统和jvm类型。AWS使用60秒,参见


PS:系统级设置始终覆盖应用程序级设置。

查看您提供的链接,似乎建议不考虑更改缓存设置。对于aws ec2,是的,因为它们对每个服务都使用dns名称。@Ravi我使用的是elasticbeanstalk Java 8 SE,默认情况下是否使用60秒?因为我知道是否有安全经理,但事实并非如此。我怎么知道是不是?如果我设置
java.security.security.setProperty(“networkaddress.cache.ttl”,“10”)