Memcached (Memcache Daemon) is a caching daemon specially designed for dynamic web applications to reduce database load by storing objects in memory. It is commonly used to speed up dynamic database-driven websites by caching data and objects in server memory to reduce the number of reads to the data source. Memcached is free and open source software licensed under the modified BSD license.
PHP Memcached vs PHP Memcached
These two PHP extensions are not the same. PHP Memcached It is old, very stable but has some limitations. The PHP Memcache module uses the daemon directly, whereas PHP Memcached uses the module libMemcached Client library and includes some additional features.
You can compare features and differences between them Here,
Installing Memcache Daemon + PHP Memcache or PHP Memcached
Before selecting the PHP extension, be sure to install the Memcache daemon:
dnf install memcached
apt update apt install memcached
After installing Memcached, open the configuration file for Memcached and make any changes:
Ubuntu / Debian:
Exit and save the configuration file, and then restart Memcached. Remember to set the Memcache daemon to start on server boot.
CentOS/Red Hat 6:
chkconfig memcached on
CentOS / Red Hat 7+:
systemctl start memcached systemctl enable memcached systemctl status memcached
Ubuntu / Debian:
Memcached is already started and enabled upon installation.
note: You can search for your Linux distribution’s package manager and install it from there.
Next, let’s install a PHP Memcache extension.
wget tar xf memcache-x.x.tgz cd memcache-x.x phpize ./configure make && make install
Then add memcache.so to your php.ini file:
yum install cyrus-sasl-devel zlib-devel gcc-c++ wget tar -xvf libmemcached-x.x.tar.gz cd libmemcached-x.x ./configure --disable-memcached-sasl make make install
Then install PHP Memcached:
wget tar xf memcached-x.x.tgz cd memcached-x.x phpize ./configure make && make install
Then add memcached.so to your php.ini file:
Finally, restart Memcached and, if necessary, Apache (and/or Nginx, etc.).
If you want to see statistics of hit rate etc., you can download Memcache PHP Stats, something that would look like this…
Published: August 29, 2015 | Last Updated: August 9, 2021