| [ Index ] |
PHP Cross Reference of Akelos Framework |
[Summary view] [Print] [Text view]
1 <?php 2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 3 4 // +----------------------------------------------------------------------+ 5 // | Akelos Framework - http://www.akelos.org | 6 // +----------------------------------------------------------------------+ 7 // | Copyright (c) 2002-2006, Akelos Media, S.L. & Bermi Ferrer Martinez | 8 // | Released under the GNU Lesser General Public License, see LICENSE.txt| 9 // +----------------------------------------------------------------------+ 10 11 12 /** 13 * @package ActionController 14 * @subpackage Caching 15 * @author Arno Schneider 16 * @license GNU Lesser General Public License <http://www.gnu.org/copyleft/lesser.html> 17 */ 18 require_once(AK_APP_DIR . DS . 'shared_model.php'); 19 require_once (AK_LIB_DIR . DS . 'AkActiveRecord' . DS . 'AkObserver.php'); 20 21 /** 22 * Cache Sweepers need to be stored under: 23 * 24 * AK_BASE_DIR/app/sweepers 25 * 26 * Sweepers are the terminators of the caching world and responsible for expiring caches when model objects change. 27 * They do this by being half-observers, half-filters and implementing callbacks for both roles. A Sweeper example: 28 * 29 * class ListSweeper extends AkCacheSweeper 30 * { 31 * var $observe = array("List", "Item"); 32 * 33 * function afterSave(&$record) { 34 * $list = is_a($record,"List") ? $record : $record->list; 35 * $this->expirePage(array("controller" => "lists", "action" => "public", "id" => $list->id)); 36 * $this->expireAction(array("controller" => "lists", "action" => "all")); 37 * foreach($list->shares as $share) { 38 * $this->expirePage(array("controller" => "lists", "action" => "show", "id" => $share->id)); 39 * } 40 * } 41 * } 42 * 43 * The sweeper is assigned in the controllers that wish to have its job performed using the <tt>$cache_sweeper</tt> class attribute: 44 * 45 * class ListsController extends ApplicationController { 46 * var $caches_action = array("index", "show", "public", "feed"); 47 * var $cache_sweeper = array("list_sweeper" => array("only" => array("edit", "destroy", "share"))); 48 * .... 49 * } 50 * 51 * In the example above, four actions are cached and three actions are responsible for expiring those caches. 52 */ 53 class AkCacheSweeper extends AkObserver 54 { 55 var $_cache_handler; 56 57 function __construct(&$cache_handler) 58 { 59 $this->_cache_handler = $cache_handler; 60 parent::__construct(); 61 } 62 function expirePage($path = null, $language=null) 63 { 64 return $this->_cache_handler->expirePage($path,$language); 65 } 66 function expireAction($options, $params = array()) 67 { 68 return $this->_cache_handler->expireAction($options, $params); 69 } 70 function expireFragment($key, $options = array()) 71 { 72 return $this->_cache_handler->expireFragment($key, $options); 73 } 74 75 76 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Oct 27 12:43:49 2008 | Cross-referenced by PHPXref 0.6 |