Nette\Caching\Cache::start PHP 메소드

start() 공개 메소드

Starts the output cache.
public start ( $key ) : OutputHelper | null
리턴 OutputHelper | null
    public function start($key)
    {
        $data = $this->load($key);
        if ($data === NULL) {
            return new OutputHelper($this, $key);
        }
        echo $data;
    }

Usage Example

예제 #1
0
 /**
  * Starts the output cache. Returns Nette\Caching\OutputHelper object if buffering was started.
  * @param  Nette\Caching\IStorage
  * @param  string
  * @param  Nette\Caching\OutputHelper[]
  * @param  array
  * @return Nette\Caching\OutputHelper
  */
 public static function createCache(Nette\Caching\IStorage $cacheStorage, $key, &$parents, array $args = NULL)
 {
     if ($args) {
         if (array_key_exists('if', $args) && !$args['if']) {
             return $parents[] = new \stdClass();
         }
         $key = array_merge([$key], array_intersect_key($args, range(0, count($args))));
     }
     if ($parents) {
         end($parents)->dependencies[Nette\Caching\Cache::ITEMS][] = $key;
     }
     $cache = new Nette\Caching\Cache($cacheStorage, 'Nette.Templating.Cache');
     if ($helper = $cache->start($key)) {
         if (isset($args['dependencies'])) {
             $args += call_user_func($args['dependencies']);
         }
         if (isset($args['expire'])) {
             $args['expiration'] = $args['expire'];
             // back compatibility
         }
         $helper->dependencies = [Nette\Caching\Cache::TAGS => isset($args['tags']) ? $args['tags'] : NULL, Nette\Caching\Cache::EXPIRATION => isset($args['expiration']) ? $args['expiration'] : '+ 7 days'];
         $parents[] = $helper;
     }
     return $helper;
 }
All Usage Examples Of Nette\Caching\Cache::start