Cache in CodeIgniter — a practical guide to CodeIgniter cache with clear examples you can reuse in real projects.
CodeIgniter Tutorial Series (60/74). Prefer one article? Read the complete CodeIgniter tutorial.
Short description
Cache computed results with a TTL. Clear or refresh when underlying data changes.
Cache remember pattern
$cache = ConfigServices::cache();
$posts = $cache->get('posts_home');
if ($posts === null) {
$posts = model('PostModel')->published();
$cache->save('posts_home', $posts, 300); // 5 minutes
}