[ Index ]

PHP Cross Reference of Akelos Framework

title

Body

[close]

/AkActionController/ -> AkCacheSweeper.php (summary)

(no description)

Author: Arno Schneider
License: GNU Lesser General Public License
File Size: 76 lines (3 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 1 file
 AkActiveRecord/AkObserver.php

Defines 1 class

AkCacheSweeper:: (4 methods):
  __construct()
  expirePage()
  expireAction()
  expireFragment()


Class: AkCacheSweeper  - X-Ref

Cache Sweepers need to be stored under:

AK_BASE_DIR/app/sweepers

Sweepers are the terminators of the caching world and responsible for expiring caches when model objects change.
They do this by being half-observers, half-filters and implementing callbacks for both roles. A Sweeper example:

class ListSweeper extends AkCacheSweeper
{
var $observe = array("List", "Item");

function afterSave(&$record) {
$list = is_a($record,"List") ? $record : $record->list;
$this->expirePage(array("controller" => "lists", "action" => "public", "id" => $list->id));
$this->expireAction(array("controller" => "lists", "action" => "all"));
foreach($list->shares as $share) {
$this->expirePage(array("controller" => "lists", "action" => "show", "id" => $share->id));
}
}
}

The sweeper is assigned in the controllers that wish to have its job performed using the <tt>$cache_sweeper</tt> class attribute:

class ListsController extends ApplicationController {
var $caches_action = array("index", "show", "public", "feed");
var $cache_sweeper = array("list_sweeper" => array("only" => array("edit", "destroy", "share")));
....
}

In the example above, four actions are cached and three actions are responsible for expiring those caches.
__construct(&$cache_handler)   X-Ref
No description

expirePage($path = null, $language=null)   X-Ref
No description

expireAction($options, $params = array()   X-Ref
No description

expireFragment($key, $options = array()   X-Ref
No description



Generated: Mon Oct 27 12:43:49 2008 Cross-referenced by PHPXref 0.6