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:

<br />
protected $valid_drivers = array('cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy', 'cache_xcache');<br />

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

Usage

Load cache drivers as usually:

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

and use as it

<br />
$this-&gt;cache-&gt;save('my_variable', array(0=&gt;'data', 1=&gt;'other data'));<br />
print_r($this-&gt;cache-&gt;get('my_variable'));<br />

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]