Memcached is a high-performance distributed memory caching system that can be used to speed up dynamic web applications by reducing the amount of time required to load data from a database. Here is an overview of the steps to install and configure Memcached on Ubuntu 18.04/20.04:
- Start by updating the package list:
sudo apt update
- Install the Memcached package:
sudo apt install memcached
- Start the Memcached service:
sudo systemctl start memcached
- Enable the Memcached service to start automatically at boot:
sudo systemctl enable memcached
- Configure Memcached by editing the configuration file located at /etc/memcached.conf. You can adjust the following settings:
-d : Run Memcached as a daemon.
-m : Set the amount of memory Memcached is allowed to use.
-l : Set the IP address to listen on.
-p : Set the port number to listen on.
-c : Set the maximum number of connections.
-u : Set the user to run Memcached as.
- Verify that Memcached is running and listening on the specified IP address and port by using the netstat command:
sudo netstat -plunt | grep memcached
- To test the installation, you can use the telnet command to connect to the Memcached server and set, get, and delete key-value pairs:
telnet localhost 11211
- To interact with Memcached, you need to install a Memcached client library for your programming language. For example, for PHP you can use the php-memcached package.
sudo apt-get install php-memcached
- you can use the memcached-tool command to get statistics on the Memcached server, like number of get and set commands, number of bytes used, and number of items stored.
memcached-tool localhost stats
Memcached is a powerful caching system that can be used to speed up dynamic web applications by reducing the amount of time required to load data from a database. It’s a simple installation and configuration process. It can be installed on Ubuntu 18.04/20.04, you can interact with Memcached via a Memcached client library for your programming language. Memcached also provides features like memcached-tool command which gives statistics on the Memcached server, like number of get and set commands, number of bytes used, and number of items stored.