I installed memcached in a CentOS following this steps
This is the PHP error:
Fatal error: Call to a member function get() on a non-object in /home/piscolab/public_html/keepyourlinks.com/includes/funciones.php on line 22
Code:
/* MEMCACHE */
$memcache = new Memcache();
$memcache->pconnect('localhost',11211);
/* checks in memcache, if not: query and save to memcache */
function cache_query($sql,$nombre,$tiempo = -1){
if($tiempo == -1) $tiempo = time() + 24*60*60*365;
$consulta = $memcache->get($nombre); /* THIS is the line */
if ( $consulta === false) {
$consulta = mysql_query($sql);
$memcache->set($nombre,$consulta,0,$tiempo);
$_SESSION['tQ']++;
}else $_SESSION['tQC']++;
return $consulta;
}
I call the function so:
$result = cache_query('select * from users','all_users');
What am I missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…