This is a very basic example of using memcache + PHP
Use at your own peril
$memcache = new Memcache; $memcache->connect("127.0.0.1"); $sql = "select * from some_huge_table where tx_date <= now()-365 limit 0, 5000"; $key = md5($sql); $query = $memcache->get($key); //the query isnt in the cache if ($query == null) { $query = $this->db->query($sql); $query = $query->result(); //put it in the cache $memcache->set($key,$query,0,600);//10 minute expiry } if (count($query) > 0) { //do something with $query } |
This example loads memcached, looks for a key, and if its not there, stores it. SIMPLE
****UPDATE****
Today while going through CI framework, I realized that CI can do its own query caching, albeit to disk. For more info on CI query caching, look go here
To change this to memcached caching should be a cinch, and indeed, it is. Head over here to see how.
So without having to change a single line of code in your application, you can take full advantage of memcached for caching query results

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 
New Blog Post -> Using memcached with PHP and CodeIgniter – http://www.zayinkrige.com/using-memcache…
Hello Zayin,
Can you tell me on which email address i should communicate to you as i am interested to talk to you for some business opportunities with IT projects?
Regards,
Gaurang Upadhyay
Email: gupadhyay@solusofttech.com
zkrige at gmail dot com
Using memcached with PHP and CodeIgniter…
This is a very basic example of using memcache + PHP Use at your own peril ?[Copy to clipboard]View Code PHP$memcache = new Memcache; $memcache->connect(“127.0.0.1″); $sql = “select * from some_huge_table…