/**
  * Initialize the proxied Cache Engine
  *
  * @param array $config Array of setting for the engine.
  * @return bool True, this engine cannot fail to initialize.
  */
 public function init(array $config = [])
 {
     if (is_object($this->_config)) {
         $this->_engine = $this->_config;
         return true;
     }
     $registry = new CacheRegistry();
     $this->_engine = $registry->load('spies', $this->_config);
     unset($registry);
     return true;
 }
Exemple #2
0
 /**
  * Finds and builds the instance of the required engine class.
  *
  * @param string $name Name of the config array that needs an engine instance built
  * @return void
  * @throws \InvalidArgumentException When a cache engine cannot be created.
  */
 protected static function _buildEngine($name)
 {
     if (empty(static::$_registry)) {
         static::$_registry = new CacheRegistry();
     }
     if (empty(static::$_config[$name]['className'])) {
         throw new InvalidArgumentException(sprintf('The "%s" cache configuration does not exist.', $name));
     }
     $config = static::$_config[$name];
     static::$_registry->load($name, $config);
     if (!empty($config['groups'])) {
         foreach ($config['groups'] as $group) {
             static::$_groups[$group][] = $name;
             static::$_groups[$group] = array_unique(static::$_groups[$group]);
             sort(static::$_groups[$group]);
         }
     }
 }