Source for file Function.php
Documentation is available at Function.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Sebastian Bergmann <sb@sebastian-bergmann.de> |
// +----------------------------------------------------------------------+
// $Id: Function.php,v 1.8 2004/12/15 09:09:33 dufuz Exp $
require_once 'Cache.php';
* Caching the result and output of functions.
* require_once 'Cache/Function.php';
* echo "foo::bar($test)<br>";
* function foobar($object) {
* echo '$'.$object.'->foobar('.$object.')<br>';
* $cache = new Cache_Function();
* $cache->call('foo::bar', 'test');
* $cache->call('bar->foobar', 'bar');
* $cache->call('foobar');
* You cannot cache every function. You should only cache
* functions that only depend on their arguments and don't use
* global or static variables, don't rely on database queries or
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @modulegroup Function_Cache
* @version $Revision: 1.8 $
* @param string Name of container class
* @param array Array with container class options
* @param integer Number of seconds for which to cache
$container_options = array ('cache_dir' => '.',
'filename_prefix' => 'cache_'
$this->Cache($container, $container_options);
* Call deconstructor of parent
* Calls a cacheable function or method.
$cached_object = $this->get($id, 'function_cache');
if ($cached_object != null ) {
// cache hit: return cached output and result
$output = $cached_object[0 ];
$result = $cached_object[1 ];
// cache miss: call function, store output and result in cache
// classname::staticMethod
list ($class, $method) = explode('::', $target);
} elseif (strstr($target, '->')) {
list ($object, $method) = explode('->', $target);
$this->save($id, array ($output, $result), $this->expires, 'function_cache');
Documentation generated on Mon, 11 Mar 2019 15:25:50 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|