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:
parent
4ab6ecc2be
commit
f8b44f24ac
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user