Source for file Function.php
Documentation is available at Function.php
* This class extends Cache_Lite and can be used to cache the result and output of functions/methods
* This class is completly inspired from Sebastian Bergmann's
* PEAR/Cache_Function class. This is only an adaptation to
* There are some examples in the 'docs/examples' file
* Technical choices are described in the 'docs/technical' file
* @version $Id: Function.php,v 1.1 2005/07/22 01:57:13 eddieajau Exp $
* @author Sebastian BERGMANN <sb@sebastian-bergmann.de>
* @author Fabien MARTY <fab@php.net>
/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
require_once( $mosConfig_absolute_path .
'/includes/Cache/Lite.php' );
// --- Private properties ---
* Default cache group for function caching
* @var string $_defaultGroup
// --- Public methods ----
* $options is an assoc. To have a look at availables options,
* see the constructor of the Cache_Lite class in 'Cache_Lite.php'
* Comparing to Cache_Lite constructor, there is another option :
* (...) see Cache_Lite constructor
* 'defaultGroup' => default cache group for function caching (string)
* @param array $options options
if (isset
($options['defaultGroup'])) {
* Calls a cacheable function or method (or not if there is already a cache for it)
* Arguments of this method are read with func_get_args. So it doesn't appear
* in the function definition. Synopsis :
* call('functionName', $arg1, $arg2, ...)
* (arg1, arg2... are arguments of 'functionName')
* @return mixed result of the function/method
$id =
serialize($arguments); // Generate a cache id
// if fileNameProtection is set to false, then the id has to be hashed
// because it's a very bad file name in most cases
$output =
$array['output'];
$result =
$array['result'];
if (strstr($target, '::')) { // classname::staticMethod
list
($class, $method) =
explode('::', $target);
} else if (strstr($target, '->')) { // object->method
// use a stupid name ($objet_123456789 because) of problems when the object
// name is the same as this var name
list
($object_123456789, $method) =
explode('->', $target);
global $
$object_123456789;
$array['output'] =
$output;
$array['result'] =
$result;
Documentation generated on Mon, 05 May 2008 16:19:47 +0400 by phpDocumentor 1.4.0