1
votes

Having issues using the PHP memcached class.

I am running a LAMP environment on Ubuntu 10.10 with Apache 2.2.16 and PHP 5.3.3. I have just installed what I thought was memcached, but seems possibly to be memcache?

I can start a new memcache object with:

$m = new Memcache;

Which works fine. But when I try and start a memcached object

$m = new Memcached();

I get the following error

Fatal error: Class 'Memcached' not found

When I run 'ps -A | grep Memcache' through the console, it returns

ben@ben-computer:/tmp$ ps -A | grep memcache
1214 ?        00:00:00 memcached

Showing a running memcached process. phpinfo() returns memcache version 2.2.6.

But when I look further into etc folder

ben@ben-computer:/etc/default$ cat memcached 
# Set this to no to disable memcached.
ENABLE_MEMCACHED=yes

Then when i run php -m it returns memcache.

You kind of get the picture, i have no idea why memcache is running instead of memcached, any help would be great.

Edit:

I think it could be an issue with libmemcached. I installed the libmemcached-dev package, but not sure if that's the same?

3
@hakre, there is a PHP class called Memcached as well.Ben
The classname is called Memcache or are you using a different extension? Like Memcached? You then need to install the Memcached extension, not the Memcache extension.hakre

3 Answers

2
votes

Memcache = name of class
Memcached = name of daemon that runs class

Similarly, cron and crond, mysql and mysqld.

2
votes

There are two different PHP classes that you can use. I recommend memcached over memcache because it is newer and supports more features.

1
votes

The memcached extension is not a standard component of PHP, and must be installed separately from PECL. Instructions are online at:

http://php.net/memcached.installation