ryxeo-glpi-git / lib / cache_lite / Lite / Output.php @ b67d8923
Historique | Voir | Annoter | Télécharger (1,62 ko)
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 |
require_once(GLPI_CACHE_LITE_DIR.'/Lite.php'); |
15 |
|
16 |
class Cache_Lite_Output extends Cache_Lite |
17 |
{ |
18 |
|
19 |
// --- Public methods ---
|
20 |
|
21 |
/**
|
22 |
* Constructor
|
23 |
*
|
24 |
* $options is an assoc. To have a look at availables options,
|
25 |
* see the constructor of the Cache_Lite class in 'Cache_Lite.php'
|
26 |
*
|
27 |
* @param array $options options
|
28 |
* @access public
|
29 |
*/
|
30 |
function Cache_Lite_Output($options) |
31 |
{ |
32 |
$this->Cache_Lite($options); |
33 |
} |
34 |
|
35 |
/**
|
36 |
* Start the cache
|
37 |
*
|
38 |
* @param string $id cache id
|
39 |
* @param string $group name of the cache group
|
40 |
* @param boolean $doNotTestCacheValidity if set to true, the cache validity won't be tested
|
41 |
* @return boolean true if the cache is hit (false else)
|
42 |
* @access public
|
43 |
*/
|
44 |
function start($id, $group = 'default', $doNotTestCacheValidity = false) |
45 |
{ |
46 |
$data = $this->get($id, $group, $doNotTestCacheValidity); |
47 |
if ($data !== false) { |
48 |
echo($data); |
49 |
return true; |
50 |
} |
51 |
ob_start(); |
52 |
ob_implicit_flush(false);
|
53 |
return false; |
54 |
} |
55 |
|
56 |
/**
|
57 |
* Stop the cache
|
58 |
*
|
59 |
* @access public
|
60 |
*/
|
61 |
function end() |
62 |
{ |
63 |
$data = ob_get_contents();
|
64 |
ob_end_clean(); |
65 |
$this->save($data, $this->_id, $this->_group); |
66 |
echo($data); |
67 |
} |
68 |
|
69 |
} |
70 |
|
71 |
|
72 |
?>
|