Exemple #1
0
 public final function show()
 {
     if (func_num_args() > 0) {
         $args = func_get_args();
         if (count($args) == 1 && is_array($args[0])) {
             $this->setValues($args[0]);
         } else {
             $this->setValues($args);
         }
     }
     if ($this->nocache) {
         echo $this->generate();
         return;
     }
     $fname = get_class($this) . '->show';
     $sname = base64_encode(gzcompress(serialize(array(get_class($this), spl_object_hash($this), 'show', $this->values))));
     $value = cache::checkFunc($fname, $sname, $result);
     if ($result === true) {
         if (strlen($value['output']) > 0) {
             echo $value['output'];
         }
         return $value['result'];
     }
     $r = null;
     ob_start();
     echo $this->generate();
     $output = ob_get_contents();
     ob_end_flush();
     return cache::func($fname, $sname, $r, $output);
 }
Exemple #2
0
 /**
  * Magic method to enable automatic caching of static functions.
  */
 public static function __callStatic($name, $args)
 {
     $realName = '_' . $name;
     $class = get_called_class();
     if (method_exists($class, 'cache_' . $name) || method_exists($class, 'ov_cache_' . $name)) {
         $fname = $class . '::' . $name;
         $sname = base64_encode(gzcompress(serialize(array($class, $name, $args))));
         $value = cache::checkFunc($fname, $sname, $result);
         if ($result === true) {
             if (strlen($value['output']) > 0) {
                 echo $value['output'];
             }
             return $value['result'];
         }
         ob_start();
         if (method_exists($class, 'ov_cache_' . $name)) {
             $r = parent::__callStatic('cache_' . $name, $args);
         } else {
             $r = call_user_func_array(array($class, 'cache_' . $name), $args);
         }
         $output = ob_get_contents();
         ob_end_flush();
         return cache::func($fname, $sname, $r, $output);
     }
     return parent::__callStatic($name, $args);
 }