我想在我的Scala-Play应用程序中为DNS查找设置TimeToLive设置。我使用Play 2.5.9和Scala 2.11.8并按照the AWS guide。我尝试以下方法:在Scala Play中设置DNS查找的TimeToLive
- 在application.conf
// Set DNS lookup time-to-live to one minute networkaddress.cache.ttl=1 networkaddress.cache.negative.ttl=1
- 中的AppModule或EagerSingleton
(该代码将是相似的)
class AppModule() extends AbstractModule { Security.setProperty("networkaddress.cache.ttl", "1") Security.setProperty("networkaddress.cache.negative.ttl", "1") ... }
传递作为环境变量:
sbt -Dsun.net.inetaddr.ttl=1 clean run
我在应用下面的一段测试代码:
for (i <- 1 to 25) {
System.out.println(java.net.InetAddress.getByName("google.com").getHostAddress())
Thread.sleep(1000)
}
这始终打印相同的IP地址,例如216.58.212.206。对我来说,看起来上面没有任何方法具有任何效果。但是,也许我正在测试其他东西,而不是实际上TTL的价值。因此,我有两个问题:
- 什么是将安全变量传递到Play应用程序的正确方法?
- 如何测试?