1
0
mirror of https://github.com/danog/dns.git synced 2024-11-30 04:29:06 +01:00

Changed default cache to be APCCache if the APC extension is loaded. This allows DNS lookups to be cached across requests when the library is used in a web SAPI.

This commit is contained in:
Danack 2014-11-19 19:20:03 +00:00
parent ebce062f63
commit 3bcf7e53a7

View File

@ -7,6 +7,7 @@ use Amp\Success;
use Amp\Failure;
use Amp\Future;
use Amp\Dns\Cache\MemoryCache;
use Amp\Dns\Cache\APCCache;
class Client {
const OP_MS_REQUEST_TIMEOUT = 0b0001;
@ -103,7 +104,17 @@ class Client {
$this->reactor = $reactor ?: \Amp\reactor();
$this->requestBuilder = $requestBuilder ?: new RequestBuilder;
$this->responseInterpreter = $responseInterpreter ?: new ResponseInterpreter;
$this->cache = $cache ?: new MemoryCache;
if (!$cache) {
if (extension_loaded('apc')) {
$cache = new APCCache;
}
else {
$cache = new MemoryCache;
}
}
$this->cache = $cache;
}
/**