Home » Centos/RHEL » How to flush cache contents of memcached server on linux system

How to flush cache contents of memcached server on linux system

memcached is open source, high-performance, distributed memory object caching system, which generally used to increase speed of dynamic database as well as websites by caching data and objects in memory (RAM) to reduce server loading time. Memcached was essentially programmed by Brad Fitzpatrick for his website and it is written in perl programming language.
If you have installed memcached server and still broadcast old contents, this article will express you that How to flush cache contents from memcached server data. You can flush all existing cache items using the flush_all command. This command will not pause the server, as it returns immediately. It connect to the memcached instance and and cancel all existing cache:
nc tool will be required to accomplish this if you already installed the nc on your system then ignore it, otherwise follow the below steps to install nc on your system.
nc is the unix/linux command also known as netcat, a plain Unix function that usually reads and writes data across network connections, using the TCP or UDP protocol.

Install the nc tool

[root@linuxpcf ~]#yum install nc
Loaded plugins: fastestmirror, replace
* base: mirror.supremebytes.com
* epel: mirror.prgmr.com
* extras: centos.sonn.com
* rpmforge: mirror.webnx.com
* updates: mirror.keystealth.org
* webtatic: us-east.repo.webtatic.com
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package nc.x86_64 0:1.85-22.el6 will be confiured
–> Finished Dependency ResolutionDependencies Resolved
===========================================================================================================
Package                                           Arch                                            Version                               Repository                            Size
=====================================================================================================================
Installing:
nc                                                     x86_64                                        1.85-22.el6                            base                                     57 k
Transaction Summary
=====================================================================================================================
Install 1 Package(s)
Total download size: 57 k
Installed size: 109 k
Is this ok [y/N]: y
Downloading Packages:
nc-1.84-22.el6.x86_64.rpm | 57 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : nc-1.84-22.el6.x86_64 1/1
Verifying : nc-1.84-22.el6.x86_64 1/1
Installed:
nc.x86_64 0:1.84-22.el6

then run the following command

[root@linuxpcf ~]#echo ‘flush_all’ | nc localhost 11211
OK

OR

[root@linuxpcf ~]#nc 192.168.1.10 11211<<<“flush_all”

Finally restart the memcached service

[root@linuxpcf ~]#service memcached restart

That’s it.

About

I am founder and webmaster of www.linuxpcfix.com and working as a Sr. Linux Administrator (Expertise on Linux/Unix & Cloud Server) and have been in the industry from last 7 years.

Leave a Reply

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

*
*

Time limit is exhausted. Please reload the CAPTCHA.

Categorized Tag Cloud