_display_cache() public method

Update/serve cached output
public _display_cache ( &$CFG, &$URI ) : boolean
return boolean TRUE on success or FALSE on failure
Ejemplo n.º 1
0
 function _display_cache(&$CFG, &$URI)
 {
     if ($this->is_logged_in) {
         // user is logged in, so don't execute the normal _display_cache
         return false;
     } else {
         // not logged in so lets try and display the cache as normal
         return parent::_display_cache($CFG, $URI);
     }
 }
Ejemplo n.º 2
0
 /**
  * An override to the CI cache reading mechanism 
  * @param object $CFG CI config object
  * @param object $URI CI uri object
  * @return 
  */
 function _display_cache(&$CFG, &$URI)
 {
     if (!function_exists('apc_add')) {
         return parent::_display_cache($CFG, $URI);
     }
     log_message('debug', 'APC Cache Check');
     $uri = $CFG->item('base_url') . $CFG->item('index_page') . $URI->uri_string;
     $cache_key = md5($uri);
     $output = apc_fetch($cache_key);
     if ($output === FALSE) {
         log_message('debug', 'APC Cache Miss..');
         return FALSE;
     } else {
         log_message('debug', 'APC Cache Hit. Sending to browser.');
     }
     # Display the cached output
     $this->_display($output);
     return TRUE;
 }
 * ------------------------------------------------------
 *  Load and instantiate the base classes
 * ------------------------------------------------------
 */
require BASEPATH . 'libraries/Config' . EXT;
require BASEPATH . 'libraries/Router' . EXT;
require BASEPATH . 'libraries/Output' . EXT;
$CFG = new CI_Config($config);
$RTR = new CI_Router($CFG);
$OUT = new CI_Output();
/*
 * ------------------------------------------------------
 *	Is there a valid cache file?  If so, we're done...
 * ------------------------------------------------------
 */
if ($OUT->_display_cache($CFG, $RTR) == TRUE) {
    exit;
}
/*
 * ------------------------------------------------------
 *  Does the requested controller exist?
 * ------------------------------------------------------
 */
if (!file_exists(APPPATH . 'controllers/' . $RTR->fetch_class() . EXT)) {
    show_404();
}
/*
 * ------------------------------------------------------
 *  Load and instantiate the remaining base classes
 * ------------------------------------------------------
 */