MediaWiki  1.28.0
MemoizedCallable.php File Reference

APC-backed and APCu-backed function memoization. More...

Go to the source code of this file.

Classes

class  MemoizedCallable
 

Detailed Description

APC-backed and APCu-backed function memoization.

This class provides memoization for pure functions. A function is pure if its result value depends on nothing other than its input parameters and if invoking it does not cause any side-effects.

The first invocation of the memoized callable with a particular set of arguments will be delegated to the underlying callable. Repeat invocations with the same input parameters will be served from APC or APCu.

Example:
$memoizedStrrev = new MemoizedCallable( 'range' );
$memoizedStrrev->invoke( 5, 8 ); // result: array( 5, 6, 7, 8 )
$memoizedStrrev->invokeArgs( array( 5, 8 ) ); // same
MemoizedCallable::call( 'range', array( 5, 8 ) ); // same

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html

Author
Ori Livneh
Since
1.27

Definition in file MemoizedCallable.php.