- rewrite this component as a helper
- use cached element
http://book.cakephp.org/2.0/en/views.html#caching-elements
- done
If you want to keep your code as a component, use beforeRender() callback
instead of beforeFilter(), example:
# app/Config/bootstrap.php
Cache::config('short', array(
....
'duration' => '+15 minutes'
));
class AppController extends Controller {
public function beforeRender() {
$wordpress_posts = Cache::read('wordpress_posts', 'short');
if (empty($wordpress_posts)) {
$wordpress_posts =
$this->Components->load('Wordpress')->getPosts();
Cache::write('wordpress_posts', $wordpress_posts, 'short');
}
$this->set('wordpress_posts', $wordpress_posts);
}
}
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php