abdfahim Posted December 18, 2008 Share Posted December 18, 2008 Hi, i want to store a mysql result resource in cache using MEMCACHE. I can store using following code, but I can't retrieve result variable from cache. Anyone can help please? $memcache = new Memcache; $memcache->connect("localhost",11211) or die ("Could not connect"); include ("dbcon.php"); $key="aa"; $sql = "select * from login_table"; $qry = mysql_query($sql) or die(mysql_error()); $result = mysql_fetch_object($qry); $memcache->set($key,$result,0,360); Link to comment https://forums.phpfreaks.com/topic/137495-memcache/ Share on other sites More sharing options...
mmarif4u Posted December 18, 2008 Share Posted December 18, 2008 May be you can use session. OR http://www.phpbuilder.com/manual/en/function.apc-store.php Link to comment https://forums.phpfreaks.com/topic/137495-memcache/#findComment-718546 Share on other sites More sharing options...
abdfahim Posted December 18, 2008 Author Share Posted December 18, 2008 yup .. i can do the same (retrieve data) using memcache also for a single variable, or an array. But the problem is when i want to restore a result set. Link to comment https://forums.phpfreaks.com/topic/137495-memcache/#findComment-718551 Share on other sites More sharing options...
abdfahim Posted December 18, 2008 Author Share Posted December 18, 2008 I meant I can restre the value from cache using $cacheresult = $memcache->get($key); but the problem i am facing is, can I treat $cacheresult as a normal SQL result resource? I tried without any success. Then how can I get all the rows of that result set? Link to comment https://forums.phpfreaks.com/topic/137495-memcache/#findComment-718553 Share on other sites More sharing options...
abdfahim Posted December 18, 2008 Author Share Posted December 18, 2008 I guess my posts are confusing a bit ... Actually my question is instead of storing each record in diff variable, can I store whole SQL result resource in cache within one variable (rather i should say one key), and then retrieve each row of that result resource? Link to comment https://forums.phpfreaks.com/topic/137495-memcache/#findComment-718555 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.