1 | <?php
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * This class extends Cache_Lite and uses output buffering to get the data to cache.
|
---|
5 | *
|
---|
6 | * There are some examples in the 'docs/examples' file
|
---|
7 | * Technical choices are described in the 'docs/technical' file
|
---|
8 | *
|
---|
9 | * @package Cache_Lite
|
---|
10 | * @version $Id: Output.php,v 1.4 2006/01/29 00:22:07 fab Exp $
|
---|
11 | * @author Fabien MARTY <fab@php.net>
|
---|
12 | */
|
---|
13 |
|
---|
14 | class net_php_pear_Cache_Lite_Output extends net_php_pear_Cache_Lite
|
---|
15 | {
|
---|
16 |
|
---|
17 | // --- Public methods ---
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Constructor
|
---|
21 | *
|
---|
22 | * $options is an assoc. To have a look at availables options,
|
---|
23 | * see the constructor of the Cache_Lite class in 'Cache_Lite.php'
|
---|
24 | *
|
---|
25 | * @param array $options options
|
---|
26 | * @access public
|
---|
27 | */
|
---|
28 | function net_php_pear_Cache_Lite_Output($options)
|
---|
29 | {
|
---|
30 | $this->net_php_pear_Cache_Lite($options);
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Start the cache
|
---|
35 | *
|
---|
36 | * @param string $id cache id
|
---|
37 | * @param string $group name of the cache group
|
---|
38 | * @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
|
---|
39 | * @return boolean true if the cache is hit (false else)
|
---|
40 | * @access public
|
---|
41 | */
|
---|
42 | function start($id, $group = 'default', $doNotTestCacheValidity = false)
|
---|
43 | {
|
---|
44 | $data = $this->get($id, $group, $doNotTestCacheValidity);
|
---|
45 | if ($data !== false) {
|
---|
46 | echo($data);
|
---|
47 | return true;
|
---|
48 | }
|
---|
49 | ob_start();
|
---|
50 | ob_implicit_flush(false);
|
---|
51 | return false;
|
---|
52 | }
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Stop the cache
|
---|
56 | *
|
---|
57 | * @access public
|
---|
58 | */
|
---|
59 | function end()
|
---|
60 | {
|
---|
61 | $data = ob_get_contents();
|
---|
62 | ob_end_clean();
|
---|
63 | $this->save($data, $this->_id, $this->_group);
|
---|
64 | echo($data);
|
---|
65 | }
|
---|
66 |
|
---|
67 | }
|
---|
68 |
|
---|
69 |
|
---|
70 | ?>
|
---|