Can't get Memcached working in PHP
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 install开发者_StackOverflow中文版ed 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?
Memcache = name of class
Memcached = name of daemon that runs class
Similarly, cron
and crond
, mysql
and mysqld
.
There are two different PHP classes that you can use. I recommend memcached over memcache because it is newer and supports more features.
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
精彩评论