-1

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?

Thread7
  • 1,081
  • 2
  • 14
  • 28

1 Answers1

1

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

Nico Haase
  • 11,420
  • 35
  • 43
  • 69
  • 1
    That was it! I did sudo apt-get install php-memcache and I didn't get the error anymore. Just for future visitors, I did not uninstall memcached. And I restarted php7.0-fpm.service and lighttpd.service. Thanks! – Thread7 Jan 27 '18 at 23:47