3 The `OutputCache` pattern caches output between calls to `start()` and `end()`.
8 use Zend\Cache\PatternFactory;
10 $outputCache = PatternFactory::factory('output', [
14 ## Configuration Options
16 Option | Data Type | Default Value | Description
17 ------ | --------- | ------------- | -----------
18 `storage` | `string | array | Zend\Cache\Storage\StorageInterface` | none | Adapter used for reading and writing cached data.
22 In addition to the methods defined in `PatternInterface`, this implementation
23 defines the following methods.
26 namespace Zend\Cache\Pattern;
28 use Zend\Cache\Exception;
30 class OutputCache extends AbstractPattern
33 * If there is a cached item with the given key, display its data, and
34 * return true. Otherwise, start buffering output until end() is called, or
37 * @param string $key Key
38 * @throws Exception\MissingKeyException if key is missing
41 public function start($key);
44 * Stop buffering output, write buffered data to the cache using the key
45 * provided to start(), and display the buffer.
47 * @throws Exception\RuntimeException if output cache not started or buffering not active
48 * @return bool TRUE on success, FALSE on failure writing to cache
50 public function end();
56 ### Caching simple view scripts
59 $outputCache = Zend\Cache\PatternFactory::factory('output', [
63 $outputCache->start('mySimpleViewScript');
64 include '/path/to/view/script.phtml';