How do I use cache in CakePHP?
caching, cakephp, php
Solution
if(!($cachedPosts = Cache::read('cached_posts'))) {
$cachedPosts = $this->Post->find('all');
Cache::write('cached_posts', $cachedPosts);
}
In this code example you look if you have the data cached - if not, retrieve it from the database, and write it to the cache. On the next request, the data will come from the cache, not from the database.
Problem
I want to use cache in CakePHP. How do I use it?