Created
November 22, 2016 19:21
-
-
Save dehora/ecaed7fd0af801a589c8e6c148c6425f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package services | |
import java.security.Security | |
import org.slf4j.LoggerFactory | |
object DnsCache { | |
private val logger = LoggerFactory.getLogger("DnsCache") | |
/** | |
* Set the dns cache settings for the jvm to stop caching names forever | |
*/ | |
def setup() { | |
val nct: String = "networkaddress.cache.ttl" | |
val ncnt: String = "networkaddress.cache.negative.ttl" | |
logger.info("cache_dns pre {}: {}", nct, Security.getProperty(nct)) | |
logger.info("cache_dns pre {}: {}", ncnt, Security.getProperty(ncnt)) | |
Security.setProperty(nct, System.getProperty("sun.net.inetaddr.ttl", "10")) | |
Security.setProperty(ncnt, System.getProperty("sun.net.inetaddr.negative.ttl", "3")) | |
logger.info("cache_dns post {}: {}", nct, Security.getProperty(nct)) | |
logger.info("cache_dns post {}: {}", ncnt, Security.getProperty(ncnt)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for java