getStorage(); $data = $storage->getItem($key, $success); if ($success) { echo $data; return true; } ob_start(); ob_implicit_flush(false); $this->keyStack[] = $key; return false; } /** * Stops buffering output, write buffered data to cache using the given key on start() * and displays the buffer. * * @throws Exception\RuntimeException If output cache not started or buffering not active. * @return bool TRUE on success, FALSE on failure writing to cache */ public function end() { $key = array_pop($this->keyStack); if ($key === null) { throw new Exception\RuntimeException('Output cache not started'); } $output = ob_get_flush(); if ($output === false) { throw new Exception\RuntimeException('Output buffering not active'); } $storage = $this->getStorage(); return $storage->setItem($key, $output); } }