XCache driver CodeIgniter

Here is a missing XCache driver for CodeIgniter Caching Class. All You need to do is to modify /system/libraries/Cache/Cache.php library and add additional Cache driver to drivers list:

protected $valid_drivers = array('cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy', 'cache_xcache');

Then you need to upload Cache_xcache.php file, to this directory: /system/libraries/Cache/drivers/


Load cache drivers as usually:

$this->load->driver('cache', array('adapter' => 'xcache'));

and use as it

$this->cache->save('my_variable', array(0=>'data', 1=>'other data'));

Due to XCache limitations You can’t store objects in cache, but you can serialize them before saving 🙂

[button link=”https://github.com/slav123/codeigniter-xcache” style=”large red rect” target=”_blank”]Download from github[/button]