Files
Testing/include/cache/handler/callback.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

55 lines
842 B
PHP

<?php
/* $Id: callback.php 8 2009-01-11 06:02:53Z john $ */
defined('SE_PAGE') or die();
class SECacheHandlerCallback extends SECache
{
function call()
{
$args = func_get_args();
$callback = array_shift($args);
return $this->get( $callback, $args );
}
function get( $callback, $args, $id=FALSE )
{
if( !$id )
{
// Generate an ID
$id = $this->_makeId($callback, $args);
}
// Get the storage handler and get callback cache data by id and group
$data = parent::get($id);
if( $data!==false )
{
$data = unserialize( $data );
}
else
{
$data = call_user_func_array($callback, $args);
$this->store(serialize($data), $id);
}
return $data;
}
function _makeId($callback, $args)
{
return md5(serialize(array($callback, $args)));
}
}