示例#1
0
 /**
  * Call the cache driver's method
  * @param string $method
  * @param array $args
  * @return mixed
  * @throws \Exception
  */
 public function __call($method, $args)
 {
     if ($this->driver->checkDriver()) {
         //由于driver中定义了__call方法,此处不能判断方法是否存在。
         return call_user_func_array(array($this->driver, $method), $args);
     }
     //fallback执行中出现异常直接捕获
     if ($this->driver->isFallback() && $this->type !== self::$config['fallback']) {
         try {
             return call_user_func_array(array($this->driver->backup(), $method), $args);
         } catch (\Exception $ex) {
             self::exception($ex);
         }
     }
     return false;
 }
示例#2
0
 /**
  * Call the cache driver's method
  * @param string $method
  * @param array $args
  * @return mixed
  * @throws \Exception
  */
 public function __call($method, $args)
 {
     if ($this->driver->checkDriver()) {
         if (method_exists($this->driver, $method)) {
             return call_user_func_array(array($this->driver, $method), $args);
         } else {
             throw new \Exception(__CLASS__ . ":{$method} is not exists!");
         }
     }
     //fallback执行中出现异常直接捕获
     if ($this->driver->isFallback() && $this->type !== self::$config['fallback']) {
         try {
             return call_user_func_array(array($this->driver->backup(), $method), $args);
         } catch (\Exception $ex) {
             CacheDriverTrait::exception($ex);
         }
     }
     return false;
 }