Memcached is a free & open-source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches.
In this guide, we will explain the steps in installing and configuring Memcached on CentOS 8.
Deploying your cloud server
If you have not already registered with Cloudwafer, you should begin by getting signed up. Take a moment to create an account after which you can quickly deploy your cloud servers.
Updating System Packages
It is recommended that you update the system to the latest packages before beginning any significant installations. Issue the command below:
sudo yum update -y
Step 1: Install Memcached
Issue the command below to install Memcached from the official CentOS repositories:
sudo dnf install memcached libmemcached
After the installation is completed, issue the command below to enable and start the Memcached service using the command below:
sudo systemctl enable memcached --now
Next, check the status by issuing the commands below:
sudo systemctl status memcached
Step 2: Configuring Memcached
The core configuration file for Memcached is the
/etc/memcached.conf file. By default, Memcached uses
11211 as the port number. You can also change this to any value of your choice.
By default, Memcached listens on the server's local IP address. You can change this if you want it to listen on a different IP by making changes in the conf file, as shown below:
sudo nano /etc/sysconfig/memcached
After saving and exiting, ensure to restart Memcached for our changes to be enforced.
sudo systemctl restart memcached
Connecting to Memcached:
Python: To connect Memcached to interact with your Python application, you can install your preferred library using pip:
pip install pymemcache pip install python-memcached