rss feed Twitter Page Facebook Page Github Page Stack Over Flow Page


Memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.


sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5-memcache memcached php5-memcached
sudo service memcached start


You can change the memcached config file for better server tuning:

sudo vi /etc/memcached.conf

Then, modify the config to have optimal settings:

modify -m 64 to -m 128

Restart memcached service

sudo /etc/init.d/memcached restart

PHP Module

The module should be enabled by default, if not you can modify:

sudo vi /etc/php5/apache2/conf.d/20-memcached.ini

Un-comment the next line to enable the module:

Or you can customize it. Here's a good example:

Restart Apache

sudo /etc/init.d/apache2 restart


Here's a simple script that will allow testing memcached:

  $mc = new Memcached();
  $mc->addServer("", 11211);

  $result = $mc->get("test_key");
  if($result) {
    echo $result;
  else {
    echo "No data on Cache. Please refresh page pressing F5";
    $mc->set("test_key", "test data pulled from Cache!") or die ("Failed to save data at Memcached server");