hostname = $baseURL->getHostname(); $this->config = $config; $this->dba = $dba; $this->profiler = $profiler; $this->logger = $logger; } /** * This method creates a CacheDriver for the given cache driver name * * @param string $type The cache type to create (default is per config) * * @return ICache The instance of the CacheDriver * @throws \Exception The exception if something went wrong during the CacheDriver creation */ public function create(string $type = null) { if (empty($type)) { $type = $this->config->get('system', 'cache_driver', self::DEFAULT_TYPE); } switch ($type) { case Cache\Type::MEMCACHE: $cache = new Cache\MemcacheCache($this->hostname, $this->config); break; case Cache\Type::MEMCACHED: $cache = new Cache\MemcachedCache($this->hostname, $this->config, $this->logger); break; case Cache\Type::REDIS: $cache = new Cache\RedisCache($this->hostname, $this->config); break; case Cache\Type::APCU: $cache = new Cache\APCuCache($this->hostname); break; default: $cache = new Cache\DatabaseCache($this->hostname, $this->dba); } $profiling = $this->config->get('system', 'profiling', false); // In case profiling is enabled, wrap the ProfilerCache around the current cache if (isset($profiling) && $profiling !== false) { return new Cache\ProfilerCache($cache, $this->profiler); } else { return $cache; } } }