Fatal Error: class 'memcache' not found

Hi all,

When trying to use the Memcache feature, I systematically get the error mentioned in the title.

I'm using PHP5-FPM with php 5.4.9 on a Ubuntu 13.04. The memcached server, libmemcached10 and the PHP memcached extension are all installed and functional: ```bash dpkg -l memcached* Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-==========================-==================-==================-=============================================== ii memcached 1.4.14-0ubuntu1 amd64 A high-performance memory object caching system```

dpkg -l libmemcached*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                       Version            Architecture       Description
+++-==========================-==================-==================-================================================
un  libmemcached               <none>                                (no description available)
ii  libmemcached10:amd64       1.0.8-1            amd64              C and C++ client library to the memcached server
un  libmemcached2              <none>                                (no description available)
un  libmemcached3              <none>                                (no description available)
un  libmemcached6              <none>                                (no description available)
un  libmemcached9              <none>                                (no description available)```

bash php5-fpm -m|grep memcache memcached```

```bash php5-fpm -i|grep memcache /etc/php5/fpm/conf.d/20-memcached.ini, memcached memcached support => enabled libmemcached version => 1.0.8 memcached.compressionfactor => 1.3 => 1.3 memcached.compressionthreshold => 2000 => 2000 memcached.compressiontype => fastlz => fastlz memcached.serializer => php => php memcached.sessbinary => 0 => 0 memcached.sesslockwait => 150000 => 150000 memcached.sesslocking => 1 => 1 memcached.sessprefix => memc.sess.key. => memc.sess.key. Registered save handlers => files user memcached```

Now, the error message I get seems to indicate that Phalcon actually uses memcache and not memcached.

If that's the case, must I implement my own backend memcached then?

Thanks, Steven



10.7k

Ok I just uninstalled memcached and installed memcache, but I get the same error message... Here's where it goes wrong: ```php $frontCache = new \Phalcon\Cache\Frontend\Data(array( 'lifetime' => 86400 )); $mcache = new \Phalcon\Cache\Backend\Memcache($frontCache, array( 'host' => 'localhost', 'port' => 11211 )); $mcache->get('some%5Fid'); // I get the error message on this call```

So what am I doing wrong?

Thanks, Steven



10.7k

This works, by the way (after uninstalling memcache and reinstalling memcached): ```php<?php $m = new Memcached(); $m->addServer('localhost', 11211);

$m->set('foo', 100); var_dump($m->get('foo')); // int 100```



10.7k

Ok I figured it out. Phalcon assumes the use of the (older) php5-memcache client instead of the (better) php5-memcached client. I can keep the memcached server, I just need to replace the memcached client by a memcache client.

I guess I'll need to write up a new backend, because there is none in the incubator either: https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Cache/Backend :)

If any moderator stops by, this question can be marked "closed".

Thanks, Steven



84.8k

I didn't know there was a better memcache extension, nice to know that :)



5.1k

i too have the same problem,

phalcon has no support for "memcached" but only "memcache", however its indsutry common knowlege and trend is to use the "memcached" as its more reliable than memcache extenstion it self. Plus php7 dont have support for the "memcache" only memcached is supported.

should write a new backend for memcached i guess soon.