phpyiimemcachedphp-7libmemcached

Have error with memcache


I am trying to get someone else's php and yii framework project working. I get this error trying to run one of their files:

Error: Call to undefined function memcache_get() in /var/yaamp/web/yaamp/core/functions/memcache.php:15

That particular section of code looks like this:

    public function get($key)
{
    return memcache_get($this->memcache, $key);
}

Your initial response may be that memcache isn't installed or not working correctly. But it is working. In my phpinfo() I see a standard entry for memcache. I also created a short php file pasted here that works just fine:

$mem_var = new Memcached();
$mem_var->addServer("127.0.0.1", 11211);
$response = $mem_var->get("Bilbo");
if ($response) {
  echo $response;
  $mem_var->set("Bilbo", "Sent from memcache") or die("Dead");
} else {
  echo "Line 9";
  $mem_var->set("Bilbo", "Sent from memcache Line 10") or die("Dead");
}

I am new to memcache and not sure how to debug or fix this. This is ubuntu 16.03, php7 and lighttpd server Any ideas?


Solution

  • Have you seen the difference between memcache and memcached? They are not the same, and if your script with new Memcached is working, but the one with memcache_get is not, then you have installed memcached, but not memcache