Cachearium\CacheAbstract::newstart PHP Method

newstart() public method

public newstart ( CacheKey $k, $lifetime = null, $fail = false )
$k CacheKey
    public function newstart(CacheKey $k, $lifetime = null, $fail = false)
    {
        // @codeCoverageIgnoreStart
        if (!$this->enabled) {
            return false;
        }
        // @codeCoverageIgnoreEnd
        // fetch cache
        try {
            $cachedata = $this->getData($k);
        } catch (Exceptions\NotCachedException $e) {
            // not cached
            if ($fail) {
                throw $e;
            }
        }
        $this->inloop++;
        $this->loopdata[$this->inloop] = new CacheData();
        if ($this->inloop > 1) {
            // we are recursive. push whatever we have so far in the previous cache
            $data = ob_get_contents();
            ob_clean();
            $this->loopdata[$this->inloop - 1]->appendData($data);
            $this->loopdata[$this->inloop - 1]->appendRecursion($k);
        } else {
            // something was not cached below. We invalidated all cache
            // dependencies
        }
        $this->loopdata[$this->inloop]->setKey($k);
        $this->loopdata[$this->inloop]->lifetime = $lifetime ? $lifetime : $this->lifetime;
        ob_start();
        ob_implicit_flush(false);
        return false;
    }