Source for file Output.php

Documentation is available at Output.php

  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.1 2005/07/22 01:57:13 eddieajau Exp $
  11. @author Fabien MARTY <fab@php.net>
  12. */
  13.  
  14. require_once('Cache/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.     * @return boolean true if the cache is hit (false else)
  41.     * @access public
  42.     */
  43.     function start($id$group 'default')
  44.     {
  45.         $data $this->get($id$group);
  46.         if ($data !== false{
  47.             echo($data);
  48.             return true;
  49.         else {
  50.             ob_start();
  51.             ob_implicit_flush(false);
  52.             return false;
  53.         }
  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. ?>

Documentation generated on Mon, 05 May 2008 16:21:41 +0400 by phpDocumentor 1.4.0