What is CodeIgniter 4's Caching system?
Answer
CodeIgniter 4 provides a unified caching API supporting multiple drivers. Configure in app/Config/Cache.php: set $handler = "redis" (or file, memcached, wincache, dummy). Get the cache service: $cache = service("cache"). Save: $cache->save("key", $data, 3600) (TTL in seconds). Get: $cache->get("key") — returns null if not found or expired. Delete: $cache->delete("key"). Clean all: $cache->clean(). Check if cached: $cache->getCacheInfo("key"). Common pattern: if (!$data = $cache->get("key")) { $data = $this->model->getExpensiveData(); $cache->save("key", $data, 3600); }. Cache entire page output with CI4's Page Cache: $this->cachePage(300) in a controller caches the full HTML response for 300 seconds.
Previous
What is the Database Forge class in CodeIgniter 4?
Next
What is CodeIgniter 4's RESTful API support?