/** * WpPepVN\Cache\Backend\Memcache constructor * * @param WpPepVN\Cache\FrontendInterface frontend * @param array options */ public function __construct(FrontendInterface $frontend, $options = null) { if (!is_array($options)) { $options = (array) $options; } if (!isset($options['servers'])) { $servers = array(array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 1)); $options['servers'] = $servers; } if (!isset($options['statsKey'])) { $options['statsKey'] = '_PEPVNCMCD'; } parent::__construct($frontend, $options); }
/** * WpPepVN\Cache\Backend\File constructor * * @param WpPepVN\Cache\FrontendInterface frontend * @param array options */ public function __construct(FrontendInterface $frontend, $options = null) { if (!isset($options['cacheDir'])) { throw new Exception('Cache directory must be specified with the option cacheDir'); } if (isset($options['safekey'])) { if (!is_bool($options['safekey'])) { throw new Exception('safekey option should be a boolean.'); } $this->_useSafeKey = $safekey; } // added to avoid having unsafe filesystem characters in the prefix if (isset($options['prefix'])) { if ($this->_useSafeKey && preg_match('/[^a-zA-Z0-9_.-]+/', $options['prefix'])) { throw new Exception('FileCache prefix should only use alphanumeric characters.'); } } parent::__construct($frontend, $options); }