I wrote a simple caching library for CodeIgniter since database caching and page output caching were not suitable for my needs.
Usage:
class Test extends Controller { function main() { // load the library $this->load->library('simple_cache'); // key is the name you have given to the cached data // will check if the item is cached if (!$this->simple_cache->is_cached('key')) { // not cached, do our things that need caching $data = array('print' => 'Hello World'); // store in cache $this->simple_cache->cache_item('key', $data); } else { $data = $this->simple_cache->get_item('key'); } $this->load->view('hello', $data); } }
I don’t think I need to explain anymore? Maybe I will update with a better description later.
I’m releasing it under the GPLv3. Enjoy.
August 30th, 2010 at 8:51 PM
Neat little caching library – thanks! Just one problem: I had to change filectime on line 51 to filemtime, as otherwise (on Windows, at least) it was failing to pick up on a file that was created long enough ago to be stale, but updated/modified recently enough to be fresh.