fix php 5.6 in docker dev env (#1740)
[openemr.git] / vendor / zendframework / zend-cache / doc / book / pattern / output-cache.md
blob6619fa6be7ed51d63f660743eea58d05e93aa37d
1 # OutputCache
3 The `OutputCache` pattern caches output between calls to `start()` and `end()`.
5 ## Quick Start
7 ```php
8 use Zend\Cache\PatternFactory;
10 $outputCache = PatternFactory::factory('output', [
11     'storage' => 'apc'
12 ]);
13 ```
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.
20 ## Available Methods
22 In addition to the methods defined in `PatternInterface`, this implementation
23 defines the following methods.
25 ```php
26 namespace Zend\Cache\Pattern;
28 use Zend\Cache\Exception;
30 class OutputCache extends AbstractPattern
32     /**
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
35      * the script ends.
36      *
37      * @param  string  $key Key
38      * @throws Exception\MissingKeyException if key is missing
39      * @return bool
40      */
41     public function start($key);
43     /**
44      * Stop buffering output, write buffered data to the cache using the key
45      * provided to start(), and display the buffer.
46      *
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
49      */
50     public function end();
52 ```
54 ## Examples
56 ### Caching simple view scripts
58 ```php
59 $outputCache = Zend\Cache\PatternFactory::factory('output', [
60     'storage' => 'apc',
61 ]);
63 $outputCache->start('mySimpleViewScript');
64 include '/path/to/view/script.phtml';
65 $outputCache->end();
66 ```