设置Java DNS缓存TTL [英] Setting Java DNS cache TTL

查看:760
本文介绍了设置Java DNS缓存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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆