To install Memcached on Ubuntu, go to terminal and type the following commands −
$sudo apt-get update $sudo apt-get install memcached
To confirm if Memcached is installed or not, you need to run the command given below. This command shows that Memcached is running on the default port 11211.
$ps aux | grep memcached
To run Memcached server on a different port, execute the command given below. This command starts the server on the TCP port 11111 and listens on the UDP port 11111 as a daemon process.
$memcached -p 11111 -U 11111 -u user -d
You can run multiple instances of Memcached server through a single installation.
To use Memcached in your Java program, you need to download spymemcached-2.10.3.jar and setup this jar into the classpath.