difference bewteen memcache and memcached

The daemon(server) of the memcache system is called memcached. You can install the memcache server using “yum install memcached”.

There are two php memcache extensions: memcache and memcached, both can work for the same memcache server mentioned before. memcache  is NOT designed to serve  another server daemon called memcache. You can install the php memcache extension using “yum install php-pecl-memcache”; you can install the php memcached extension using “yum install php-pecl-memcached”. The php module name for  memcache is called “memcache” and the mudule name for the php memcached extension is “memcached” so be sure to use the correct one in calling the extension_loaded() function. You can check if the extensions are correctly installed by “php -m|grep memcache”. The module names are also displayed in the output of phpinfo(). The .so file for the memcache extension is put in /usr/lib64/php/modules/memcache.so, and the configuration parameters are set in /etc/php.d/memcache.ini. The .so file for the memcached extension is /usr/lib64/php/modules/memcached.so and its configuration parameters can be found in /etc/php.d/z-memcached.ini. You can no longer find the configuration parameters for php extensions in /etc/php.ini now.

After installing the php extension(s)(you can install one of them or install both, they won’t conflict with each other), you can use them in your php files. The class name for the memcache extension is “Memcache” and the class name for the memcached extension is “Memcached”. Their usage is almost the same:

For Memcache, you can replace addServer with connect, but memcached has not the connect function.

Posted in tips of hosting