/**
  * Initialize the cache engine
  *
  * Called automatically by the cache frontend. Merge the runtime config with the defaults
  * before use.
  *
  * @param array $config Associative array of parameters for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     parent::init($config);
     $this->client = new Client($this->_config['connections'], $this->_config['options']);
     $this->client->connect();
     return $this->client->isConnected();
 }
Exemple #2
0
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     if (!extension_loaded('wincache')) {
         return false;
     }
     parent::init($config);
     return true;
 }
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     if (PHP_SAPI === 'cli' || !extension_loaded('xcache')) {
         return false;
     }
     parent::init($config);
     return true;
 }
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     if (!isset($config['prefix'])) {
         $config['prefix'] = Inflector::slug(APP_DIR) . '_';
     }
     parent::init($config);
     return function_exists('apc_dec');
 }
Exemple #5
0
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     if (php_sapi_name() !== 'cli') {
         parent::init($config);
         return function_exists('xcache_info');
     }
     return false;
 }
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     if (!class_exists('Redis')) {
         return false;
     }
     parent::init($config);
     return $this->_connect();
 }
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     if (!extension_loaded('redis')) {
         return false;
     }
     parent::init($config);
     return $this->_connect();
 }
Exemple #8
0
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     if (!extension_loaded('redis')) {
         return false;
     }
     if (!empty($config['host'])) {
         $config['server'] = $config['host'];
     }
     parent::init($config);
     return $this->_connect();
 }
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     if (php_sapi_name() !== 'cli') {
         if (!isset($config['prefix'])) {
             $config['prefix'] = Inflector::slug(APP_DIR) . '_';
         }
         parent::init($config);
         return function_exists('xcache_info');
     }
     return false;
 }
 /**
  * Gets a translator from the registry by package for a locale.
  *
  * @param string $name The translator package to retrieve.
  * @param string|null $locale The locale to use; if empty, uses the default
  * locale.
  * @return \Aura\Intl\TranslatorInterface A translator object.
  * @throws \Aura\Intl\Exception If no translator with that name could be found
  * for the given locale.
  */
 public function get($name, $locale = null)
 {
     if (!$name) {
         return null;
     }
     if ($locale === null) {
         $locale = $this->getLocale();
     }
     if (isset($this->registry[$name][$locale])) {
         return $this->registry[$name][$locale];
     }
     if (!$this->_cacher) {
         return $this->registry[$name][$locale] = $this->_getTranslator($name, $locale);
     }
     $key = "translations.{$name}.{$locale}";
     $translator = $this->_cacher->read($key);
     if (!$translator) {
         $translator = $this->_getTranslator($name, $locale);
         $this->_cacher->write($key, $translator);
     }
     return $this->registry[$name][$locale] = $translator;
 }
 /**
  * Initialize File Cache Engine
  *
  * Called automatically by the cache frontend.
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     parent::init($config);
     if (DS === '\\') {
         $this->_config['isWindows'] = true;
     }
     if (substr($this->_config['path'], -1) !== DS) {
         $this->_config['path'] .= DS;
     }
     if (!empty($this->_groupPrefix)) {
         $this->_groupPrefix = str_replace('_', DS, $this->_groupPrefix);
     }
     return $this->_active();
 }
Exemple #12
0
 /**
  * Initialize File Cache Engine
  *
  * Called automatically by the cache frontend.
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     parent::init($config);
     if ($this->_config['path'] === null) {
         $this->_config['path'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'cake_cache' . DIRECTORY_SEPARATOR;
     }
     if (DIRECTORY_SEPARATOR === '\\') {
         $this->_config['isWindows'] = true;
     }
     if (substr($this->_config['path'], -1) !== DIRECTORY_SEPARATOR) {
         $this->_config['path'] .= DIRECTORY_SEPARATOR;
     }
     if (!empty($this->_groupPrefix)) {
         $this->_groupPrefix = str_replace('_', DIRECTORY_SEPARATOR, $this->_groupPrefix);
     }
     return $this->_active();
 }
Exemple #13
0
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     parent::init($config);
     return function_exists('apc_dec');
 }
Exemple #14
0
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  * @throws \InvalidArgumentException When you try use authentication without
  *   Memcached compiled with SASL support
  */
 public function init(array $config = [])
 {
     if (!extension_loaded('memcached')) {
         return false;
     }
     $this->_serializers = ['igbinary' => Memcached::SERIALIZER_IGBINARY, 'json' => Memcached::SERIALIZER_JSON, 'php' => Memcached::SERIALIZER_PHP];
     if (defined('Memcached::HAVE_MSGPACK') && Memcached::HAVE_MSGPACK) {
         $this->_serializers['msgpack'] = Memcached::SERIALIZER_MSGPACK;
     }
     parent::init($config);
     if (!empty($config['host'])) {
         if (empty($config['port'])) {
             $config['servers'] = [$config['host']];
         } else {
             $config['servers'] = [sprintf('%s:%d', $config['host'], $config['port'])];
         }
     }
     if (isset($config['servers'])) {
         $this->config('servers', $config['servers'], false);
     }
     if (!is_array($this->_config['servers'])) {
         $this->_config['servers'] = [$this->_config['servers']];
     }
     if (isset($this->_Memcached)) {
         return true;
     }
     if ($this->_config['persistent']) {
         $this->_Memcached = new Memcached((string) $this->_config['persistent']);
     } else {
         $this->_Memcached = new Memcached();
     }
     $this->_setOptions();
     if (count($this->_Memcached->getServerList())) {
         return true;
     }
     $servers = [];
     foreach ($this->_config['servers'] as $server) {
         $servers[] = $this->_parseServerString($server);
     }
     if (!$this->_Memcached->addServers($servers)) {
         return false;
     }
     if (is_array($this->_config['options'])) {
         foreach ($this->_config['options'] as $opt => $value) {
             $this->_Memcached->setOption($opt, $value);
         }
     }
     if (empty($this->_config['username']) && !empty($this->_config['login'])) {
         throw new InvalidArgumentException('Please pass "username" instead of "login" for connecting to Memcached');
     }
     if ($this->_config['username'] !== null && $this->_config['password'] !== null) {
         $sasl = method_exists($this->_Memcached, 'setSaslAuthData') && ini_get('memcached.use_sasl');
         if (!$sasl) {
             throw new InvalidArgumentException('Memcached extension is not build with SASL support');
         }
         $this->_Memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
         $this->_Memcached->setSaslAuthData($this->_config['username'], $this->_config['password']);
     }
     return true;
 }
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init(array $config = [])
 {
     parent::init($config);
     return function_exists('wincache_ucache_info');
 }
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  *
  * @param array $config array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  * @throws \Cake\Error\Exception when you try use authentication without Memcached compiled with SASL support
  */
 public function init(array $config = [])
 {
     if (!class_exists('Memcached')) {
         return false;
     }
     if (!isset($config['prefix'])) {
         $config['prefix'] = Inflector::slug(APP_DIR) . '_';
     }
     if (defined('Memcached::HAVE_MSGPACK') && Memcached::HAVE_MSGPACK) {
         $this->_serializers['msgpack'] = Memcached::SERIALIZER_MSGPACK;
     }
     parent::init($config);
     if (isset($config['servers'])) {
         $this->config('servers', $config['servers'], false);
     }
     if (!is_array($this->_config['servers'])) {
         $this->_config['servers'] = [$this->_config['servers']];
     }
     if (isset($this->_Memcached)) {
         return true;
     }
     $this->_Memcached = new \Memcached($this->_config['persistent'] ? (string) $this->_config['persistent'] : null);
     $this->_setOptions();
     if (count($this->_Memcached->getServerList())) {
         return true;
     }
     $servers = [];
     foreach ($this->_config['servers'] as $server) {
         $servers[] = $this->_parseServerString($server);
     }
     if (!$this->_Memcached->addServers($servers)) {
         return false;
     }
     if ($this->_config['login'] !== null && $this->_config['password'] !== null) {
         if (!method_exists($this->_Memcached, 'setSaslAuthData')) {
             throw new Error\Exception('Memcached extension is not build with SASL support');
         }
         $this->_Memcached->setSaslAuthData($this->_config['login'], $this->_config['password']);
     }
     return true;
 }