1
0
mirror of https://github.com/danog/dns.git synced 2025-01-23 05:51:11 +01:00

Allow injecting of cache through factory

This commit is contained in:
Chris Wright 2014-06-15 23:36:17 +01:00
parent 4ab6ecc2be
commit f8b44f24ac

View File

@ -17,6 +17,7 @@ class ResolverFactory
* @param string $serverAddr
* @param int $serverPort
* @param int $requestTimeout
* @param Cache $cache
* @param string $hostsFilePath
* @return Resolver
*/
@ -25,6 +26,7 @@ class ResolverFactory
$serverAddr = null,
$serverPort = null,
$requestTimeout = null,
Cache $cache = null,
$hostsFilePath = null
) {
$nameValidator = new NameValidator;
@ -42,7 +44,7 @@ class ResolverFactory
$serverAddr, $serverPort, $requestTimeout
);
$cache = new MemoryCache;
$cache = $cache ?: new MemoryCache;
$hostsFile = new HostsFile($nameValidator, $hostsFilePath);
return new Resolver($reactor, $nameValidator, $client, $cache, $hostsFile);