| 
      
 
	回到缓存对象的构造函数,接下来执行_getFrontendOptions函数,它去寻找frontend_options节点,设置是否缓存 和 缓存时间,参考以上给出的配置文件。 
	接下执行: 
	
		
			
				
					| 
						 
							1 
						
							2 
						
							3 
					 | 
					
						
							
								$this->_frontend = Zend_Cache::factory('Varien_Cache_Core', $backend['type'], $frontend, $backend['options'], 
							
								            true, true, true 
							
								        ); 
						 
					 | 
				 
			
		 
	 
 
	实际利用Zend_Cache生成了一个缓存对象(Varien_Cache_Core继承自Zend_Cache_Core),它保存到缓存对象的_frontend中(****)。 
	通过App的_initCache,它的_cache字段都保持了一份Mage_Core_Model_Cache对象的引用(注意它内部的__frontend,它应该才是核心)。 
	现在把目光转移回到App的run方法中,看如下代码: 
	
		
			
				
					| 
						 
							1 
						
							2 
						
							3 
					 | 
					
						
							
								if ($this->_cache->processRequest()) { 
							
								    $this->getResponse()->sendResponse(); 
							
								} else {} 
						 
					 | 
				 
			
		 
	 
 
	这里调用缓存对象的processRequest,如果顺利,可以直接响应。那么去看看processRequest方法: 
	
		
			
				
					| 
						 
							1 
						
							2 
						
							3 
						
							4 
						
							5 
						
							6 
						
							7 
						
							8 
						
							9 
						
							10 
						
							11 
						
							12 
						
							13 
						
							14 
						
							15 
						
							16 
						
							17 
						
							18 
						
							19 
						
							20 
					 | 
					
						
							
								public function processRequest() 
							
								{ 
							
								    if (empty($this->_requestProcessors)) { 
							
								        return false; 
							
								    } 
							
								  
							
								    $content = false; 
							
								    foreach ($this->_requestProcessors as $processor) { 
							
								        $processor = $this->_getProcessor($processor); 
							
								        if ($processor) { 
							
								            $content = $processor->extractContent($content); 
							
								        } 
							
								    } 
							
								  
							
								    if ($content) { 
							
								        Mage::app()->getResponse()->appendBody($content); 
							
								        return true; 
							
								    } 
							
								    return false; 
							
								} 
						 
					 | 
				 
			
		 
	 
 
	马上就有疑问,_requestProcessors如何被设置的,好吧,在构造函数中,刚才少说了如下代码: 
	
		
			
				
					| 
						 
							1 
						
							2 
						
							3 
						
							4 
					 | 
					
						
							
								// Mage_Core_Model_Cache 
							
								        if (isset($options['request_processors'])) { 
							
								            $this->_requestProcessors = $options['request_processors']; 
							
								        } 
						 
					 | 
				 
			
		 
	
      
      (责任编辑:最模板)    |