Zend_Cache_Frontend_Class is different from
Zend_Cache_Frontend_Function because it allows caching of
object and static method calls.
Table 22. Class Frontend Options
| Option | Data Type | Default Value | Description |
|---|---|---|---|
| cached_entity (required) | Mixed | if set to a class name, we will cache an abstract class and will use only static calls; if set to an object, we will cache this object methods | |
| cache_by_default | Boolean | TRUE |
if TRUE, calls will be cached by default
|
| cached_methods | Array | method names which will always be cached | |
| non_cached_methods | Array | method names which must never be cached |
For example, to cache static calls :
<?php
class Test {
// Static method
public static function foobar($param1, $param2) {
echo "foobar_output($param1, $param2)";
return "foobar_return($param1, $param2)";
}
}
// [...]
$frontendOptions = array(
'cached_entity' => 'Test' // The name of the class
);
// [...]
// The cached call
$result = $cache->foobar('1', '2');
To cache classic method calls :
<?php
class Test {
private $_string = 'hello !';
public function foobar2($param1, $param2) {
echo($this->_string);
echo "foobar2_output($param1, $param2)";
return "foobar2_return($param1, $param2)";
}
}
// [...]
$frontendOptions = array(
'cached_entity' => new Test() // An instance of the class
);
// [...]
// The cached call
$result = $cache->foobar2('1', '2');




