Simple Cache Library for CodeIgniter

Note: This library has only been tested with the 1.7 branch of CodeIgniter. It has not been tested with CodeIgniter 2.0.

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.

Download simple-cache.7z