From 980c7c91303e6cf0646809af293a8bb4126a5ca0 Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Wed, 26 Nov 2014 16:02:43 +0000 Subject: [PATCH] Add CacheFactory --- lib/CacheFactory.php | 23 +++++++++++++++++++++++ lib/Client.php | 14 +------------- 2 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 lib/CacheFactory.php diff --git a/lib/CacheFactory.php b/lib/CacheFactory.php new file mode 100644 index 0000000..8aee8a0 --- /dev/null +++ b/lib/CacheFactory.php @@ -0,0 +1,23 @@ +reactor = $reactor ?: \Amp\reactor(); $this->requestBuilder = $requestBuilder ?: new RequestBuilder; $this->responseInterpreter = $responseInterpreter ?: new ResponseInterpreter; - - if (!$cache) { - if (extension_loaded('apc') && ini_get("apc.enabled") && @apc_cache_info()) { - $cache = new APCCache; - } - else { - $cache = new MemoryCache; - } - } - - $this->cache = $cache; + $this->cache = $cache ?: (new CacheFactory)->select(); } /**