PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Zend_Cache_Frontend_Function

Introduction

Zend_Cache_Frontend_Function caches the results of function calls. It has a single main method named call() which takes a function name and parameters for the call in an array.

Available Options

Table 21. Function Frontend Options

Option Data Type Default Value Description
cache_by_default Boolean TRUE if TRUE, function calls will be cached by default
cached_functions Array   function names which will always be cached
non_cached_functions Array   function names which must never be cached

Examples

Using the call() function is the same as using call_user_func_array() in PHP:

<?php
$cache
->call('veryExpensiveFunc'$params);

// $params is an array
// For example to call veryExpensiveFunc(1, 'foo', 'bar') with
// caching, you can use
// $cache->call('veryExpensiveFunc', array(1, 'foo', 'bar'))

Zend_Cache_Frontend_Function is smart enough to cache both the return value of the function and its internal output.

Note

You can pass any built in or user defined function with the exception of array(), echo(), empty(), eval(), exit(), isset(), list(), print() and unset().

Zend Framework