/** * Constructor * * @param array $config */ function __construct($config = array()) { parent::__construct($config); if (isset($config['cache_dir'])) { $this->_cache_dir = trim($config['cache_dir']); } else { $this->_cache_dir = w3_cache_blog_dir($config['section'], $config['blog_id']); } $this->_exclude = isset($config['exclude']) ? (array) $config['exclude'] : array(); $this->_flush_timelimit = isset($config['flush_timelimit']) ? (int) $config['flush_timelimit'] : 180; $this->_locking = isset($config['locking']) ? (bool) $config['locking'] : false; if (isset($config['flush_dir'])) { $this->_flush_dir = $config['flush_dir']; } else { if ($config['blog_id'] <= 0) { // clear whole section if we operate on master cache $this->_flush_dir = w3_cache_dir($config['section']); } else { $this->_flush_dir = $this->_cache_dir; } } if (isset($config['use_wp_hash']) && $config['use_wp_hash'] && function_exists('wp_hash')) { $this->_use_wp_hash = true; } }
/** * constructor * * @param array $config */ function __construct($config) { parent::__construct($config); $this->_memcache = new Memcache(); if (!empty($config['servers'])) { $persistant = isset($config['persistant']) ? (bool) $config['persistant'] : false; foreach ((array) $config['servers'] as $server) { if (substr($server, 0, 5) == 'unix:') { $this->_memcache->addServer(trim($server), 0, $persistant); } else { list($ip, $port) = explode(':', $server); $this->_memcache->addServer(trim($ip), (int) trim($port), $persistant); } } } else { return false; } if (!empty($config['compress_threshold'])) { $this->_memcache->setCompressThreshold((int) $config['compress_threshold']); } return true; }