CodeIgniter Forums
Cache library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Cache library (/showthread.php?tid=25792)

Pages: 1 2


Cache library - El Forum - 12-25-2009

[eluser]Sbioko[/eluser]
Hi all! Today, I want to represent you my new library! This will be a part of my CMS. But I want to share it with everyone! Supports Memcached, XCache, eAccelerator, APC and Native implementation of caching.

Installation:
Unpack Cache.zip. Move Cache.php to your application/libraries folder. Then move cache_config.php to your application/config folder AND rename it to cache.php. That's it!

How to use it:
Syntax is very easy, but if you need more samples, feel free to say!
Code:
$this->load->library('cache');
$this->cache->driver('xcache'); // Can be also memcached, apc, fs(file system) and eaccelerator
$this->cache->set('test_key', 'Test Value'); // Storing some value
//Then, we will do some checking for our data
if($this->cache->exists('test_key'))
{
   echo $this->cache->get('test_key');
}
//After that, just cleaning. First, we will delete test_key and then, all the cache
$this->cache->delete('test_key');
$this->cache->clean();

Also, I've implemented such methods as:
Code:
$this->cache->increment('test_key');
$this->cache->decrement('test_key');
$this->cache->is_loaded('driver'); // Where driver is memcached, xcache, apc, eaccelerator

Warning: I didn't test it with Memcached, eAccelerator. Please, if you can do it, pm me about your results.


Cache library - El Forum - 12-31-2009

[eluser]Phil Sturgeon[/eluser]
Good stuff. I never quite got around to adding Memcache to my Cache library. One of those "I'll do it next week" jobs I never bothered with.

I'm not sure I like your suggestion that people put this library in the system/libraries folder, and its a bit strange that you called your library CI_Class as it is not. Third-party libraries should be kept in application/libraries so system can be blammed at any point for a new version.


Cache library - El Forum - 12-31-2009

[eluser]Sbioko[/eluser]
I think, if you don't like that I named it with CI_ prefix, you can easily change it to yours. This is not a big problem.


Cache library - El Forum - 12-31-2009

[eluser]Phil Sturgeon[/eluser]
Just call it class Cache, it's not a core library. It's not a complaint just take the feedback.


Cache library - El Forum - 12-31-2009

[eluser]Sbioko[/eluser]
Ok, I will do it in the next version. Thank you for discussion!


Cache library - El Forum - 08-23-2010

[eluser]dungdn[/eluser]
I have an error when use this library with memcache:

Fatal error: Call to a member function set() on a non-object in E:\UniServer50\www\ione\includes\system\libraries\Cache.php on line 125

Can anyone show me the reason why..???


Cache library - El Forum - 08-24-2010

[eluser]echoDreamz[/eluser]
Sweet, could you look into adding Wincache?
http://php.net/manual/en/book.wincache.php

Its a new opcode caching mechanism developed by Microsoft specifically designed for IIS and Windows.


Cache library - El Forum - 08-24-2010

[eluser]InsiteFX[/eluser]
As Phil pointed out to you above, if you read the
CodeIgniter Users Guide you would have read this!

Please note that all native CodeIgniter libraries are prefixed with CI_ so DO NOT use that as your prefix.

InsiteFX


Cache library - El Forum - 08-25-2010

[eluser]RaZoR LeGaCy[/eluser]
I am awaiting the next version with the proper class names and waiting to see if I can replace a current memcache version using zend framework.


Cache library - El Forum - 08-30-2010

[eluser]Sbioko[/eluser]
Bang bang! Update!
-Fixed memcache error.
-Code is more beautiful now
-Added simple validations
-PHP5 only
-Changed class name

Tell me, if something wrong. :-)