Introduction To Memcached with Telnet and Python – POFTUT

Introduction To Memcached with Telnet and Python

We have successfully installed and stated Memcached. Now we will simply connect to the Memcached and work simple operations.

Connect To The Memcached with Telnet

The simples tool to connect Memcached and make operations is telnet. Memcached default tcp port is 11211 so to connect memcached we will issue following commands.

Set Simple Value to Memcached with Telnet

We will set simple value to the memcached to test it.

Ok there is no problem it seems. Using telnet is the simplest way but not a productive and practical way. So to store values into the Memcached we will write some applications in different languages. We prefer here python because its simplicity and popularity.

Install Python3 for Memcached

We will install python3 libraries for Memcached. There are alternatives for libraries by the way.

Write Simple Python App for Memcached

Open python3 interactive shell for issuing commands.

Import Memcached library to the shell.

LEARN MORE  How To Ping Specified Port Number?

echo '

Create a connection to the Memcached services with default settings.

Create some data as python dictionary object.

Add the data to the Memcached with “sample” tag and for 15 minutest. After 15 minutes our object will be automatically deleted.

All of the code

Leave a Reply

Your email address will not be published. Required fields are marked *