设置Java DNS缓存TTL [英] Setting Java DNS cache TTL
问题描述
我正在尝试更改Java 1.6中的DNS缓存超时。我看到 here 使用某些内容如下:
I'm attempting to change the DNS cache timeout in Java 1.6. I see discussion here of using something like the following:
java.security.Security.setProperty ("networkaddress.cache.ttl" , TTL_SECS);
但是我在Win 7 ....中尝试过这个简单的测试。
But I've tried this simple test in Win 7....
System.out.println("DEFAULT DNS TTL: "+sun.net.InetAddressCachePolicy.get());
java.security.Security.setProperty ("networkaddress.cache.ttl" , "123");
System.out.println("DEFAULT DNS TTL: "+sun.net.InetAddressCachePolicy.get());
...,输出不变。似乎这可以在Java安装的安全属性中进行更改,但我预先将其保留在代码中。任何想法如何实现?
... and the output doesn't change. It seems this can be changed in the Java installation's security properties but I preffer to keep this in the code for neatness. Any ideas how to achieve that?
谢谢。
推荐答案
这些不是系统属性:在java.security文件中设置。对于非首选的相应系统属性,请参阅网络属性。
These are not system properties: they are set in the java.security file. For the corresponding system properties, which are non-preferred, see 'Sun implementation-specific properties' in Networking Properties.
这篇关于设置Java DNS缓存TTL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!