I am using cakephp 2.1.1 for my app. I have a controller and I use the file cache in this controller. In the actions of the controller I call a SOAPService using the plugin NUSOAP.
I have two actions:
1. index
public function index() {
$items = Cache::read('items', 'tenMinutes'); //tenMinutes is the configuration of cache
if($items){
$service = new Service();
$items = $service->callService();
Cache::write('items',$items,'tenMinutes');
}
$this->set('items',$items);
}
2. get_result
public function get_result() {
$items = Cache::read('items','tenMinutes');
if($items){
//start block code filter items by params
...
//end
$service = new Service();
$result = $service->callService2($items);
$this->set('result',$result);
} else {
//redirect index to load ítems
$this->redirect(array('controller' =>'controllerName', 'action' => 'index'));
}
}
The configuration of cache is:
Cache::config('tenMinutes', array(
'engine' => 'File', //[required]
'duration'=> '10 minutes', //[optional]
'path' => CACHE, //[optional] use system tmp directory - remember to use absolute path
'prefix' => 'cake_10_', //[optional] prefix every cache file with this string
));
When I call index action and is the first time that cakephp writes in cache I have the following error:
Fatal error: Cannot call constructor in C:\wamp\www\myapp\lib\Cake\View\Helper\HtmlHelper.php on line 172
The second time I enter index and cache is already filled I click the button to take me to the second action (get_result), and this returns me the same error.
Can someone help me?
Thanks