user606521
user606521

Reputation: 15434

cake php element cache

I can't make element caching work:

echo $this->element('categorytree', array(
    'cache' => array(
        'key'=>'categorytree-cache','time' => '+1 hour'
    )
))

I checked core.php:

// In development mode, caches should expire quickly.
$duration = '+999 days';
/*if (Configure::read('debug') >= 1) {
    $duration = '+10 seconds';
}*/

And commented as you see - to prevent short caching in debug mode...

But still when I refresh page the SQL query that cached element does by requestAction() is shown... So no caching... why?

Upvotes: 1

Views: 929

Answers (1)

dr Hannibal Lecter
dr Hannibal Lecter

Reputation: 6721

I may be wrong here, but I think the correct call would be:

echo $this->element('categorytree', array(), array(
    'cache' => array(
        'key'=>'categorytree-cache','time' => '+1 hour'
    )
))

Notice the second argument is element params while the third is element options (what you need here).

You can see the function signature here.

Upvotes: 1

Related Questions