33namespace React \Dns \Resolver ;
44
55use React \Cache \ArrayCache ;
6+ use React \Cache \CacheInterface ;
67use React \Dns \Query \Executor ;
78use React \Dns \Query \CachedExecutor ;
89use React \Dns \Query \RecordCache ;
@@ -21,10 +22,14 @@ public function create($nameserver, LoopInterface $loop)
2122 return new Resolver ($ nameserver , $ executor );
2223 }
2324
24- public function createCached ($ nameserver , LoopInterface $ loop )
25+ public function createCached ($ nameserver , LoopInterface $ loop, CacheInterface $ cache = null )
2526 {
27+ if (!($ cache instanceof CacheInterface)) {
28+ $ cache = new ArrayCache ();
29+ }
30+
2631 $ nameserver = $ this ->addPortToServerIfMissing ($ nameserver );
27- $ executor = $ this ->createCachedExecutor ($ loop );
32+ $ executor = $ this ->createCachedExecutor ($ loop, $ cache );
2833
2934 return new Resolver ($ nameserver , $ executor );
3035 }
@@ -39,9 +44,9 @@ protected function createRetryExecutor(LoopInterface $loop)
3944 return new RetryExecutor ($ this ->createExecutor ($ loop ));
4045 }
4146
42- protected function createCachedExecutor (LoopInterface $ loop )
47+ protected function createCachedExecutor (LoopInterface $ loop, CacheInterface $ cache )
4348 {
44- return new CachedExecutor ($ this ->createRetryExecutor ($ loop ), new RecordCache (new ArrayCache () ));
49+ return new CachedExecutor ($ this ->createRetryExecutor ($ loop ), new RecordCache ($ cache ));
4550 }
4651
4752 protected function addPortToServerIfMissing ($ nameserver )
0 commit comments