Test Memcached using Telnet Commands

Published on February 7, 2020 51 sec read

In this short article, we’re going to learn how to test Memcached using Telnet.

By running this command, we can see the port where Memcached is running:

ps -eaf | grep memcached

Table of Contents

  1. Connect to Memcached Server
  2. Store Data
  3. Retrieve Data
  4. Replace Existing Data
  5. Delete Data by Key
  6. Server Statistics
  7. Clear All Cache

Connect to Memcached Server

Run this command to connect to the Memcached server:

# structure
telnet hostname/ip port

# example
telnet 11211
telnet localhost 11211

Store Data

To store data in Memcached, we have to run the command like this:

# structure
set key_name meta_data expiry_time length_in_bytes

# example
set Test 0 100 5 # press enter
Hello # press enter

STORED # you'll see this message after storing

Retrieve Data

We can easily get stored data using the key name:

# structure
get key_name

# example
get Test

Replace Existing Data

We can also replace the existing stored data:

# structure
replace key_name meta_data expiry_time length_in_bytes

# example
replace Test 0 100 11 # press enter
Hello World # press enter

STORED # you'll see this message after storing

Delete Data by Key

To delete any stored data, just run the command like:

# structure
delete key_name

# example
delete Test

Server Statistics

We can see the Memcached server statistics using these commands:

stats items
stats slabst

Clear All Cache

To delete all cached data, we have run the command:


We know that using quit command, we have to exit the telnet session.

The tutorial is over. Thank you. 🙂

Monthly Newsletter

One email a month, packed with the latest tutorials, delivered straight to your inbox.
We'll never send any spam or promotional emails.

Hey, I'm Md Obydullah. I build open-source projects and write article on Laravel, Linux server, modern JavaScript and more on web development.