Welcome Guest, Not a member yet? Register   Sign In
Memcache DB_cache Replacement
#1

[eluser]John Bellone[/eluser]
Hey guys,

I have been working with CI now for a couple of months for <a href="http://zinkkinc.com/">my startup</a> and we thought we'd start putting out some of our code for community review. So far the community has been great, and we've really not had anything substantial to contribute until now. So here's a little something something we've been using. Let us know if you guys see any improvements, and feel free to leave suggestions.

We are planning on putting up a git repository on our website at <a href="http://code.zinkkinc.com/">http://code.zinkkinc.com/</a> but I have not had the chance to do so yet. If all goes well I'll have that going by Monday morning, and we'll have a proper place to display our contributions.

<b>Memcache Replacement for Standard DB Disk cache</b>

As I said above we work with heavy database applications and we are always looking for ways to speed up our web applications' queries. So I took a couple of hours and rewrote the release version of <i>DB_cache.php</i> to use memcache where available, and if not fall back to disk caching. I'm attaching the file to the post, and the only thing that you have to is add the following entry to your database configuration:

Quote:$db['default']['mc_hosts'][] = array ("ip"=>'127.0.0.1', "port"=>11211);

If you find any bugs, have any questions, or find a better way to do something feel free to reply to the thread, or shoot me an e-mail <a href="mailto:[email protected]">jb at zinkkinc.com</a>. Thanks all, we've had some awesome fun with CI and hope to be able to contribute to everyone.
#2

[eluser]Matthieu Fauveau[/eluser]
Nice one, I'm gonna try it as soon as possible.

Thanks for sharing !
#3

[eluser]John Bellone[/eluser]
Caught a bug myself after wondering why some of the entries in our system were from Thursday. The quick fix is to replace <b>Line 106</b> with the following tidbit of code:
Quote: return memcache_set ($this->MC, md5 ($segment_one . $segment_two . $sql), $object, 0, $expires);
The fourth parameter in the function is for compression, and the last is for expires. So if expires is zero items inside of the cache last indefinitely (which basically amounts to until they get written over).




Theme © iAndrew 2016 - Forum software by © MyBB