4

I would like to flush the memcached cache keys and values on my centos server.

I have tried the telnet approach by telnetting to the port and then issuing: flush_all

It doesn't work an my values are still cached.

Does anyone know how I can accomplish this?

petey
  • 572
  • 3
  • 9
  • 20
  • What is the "this" you are trying to accomplish exactly? What is the problem you are trying to solve? The `flush_all` command doesn't remove anything from the cache. It just marks the entries invalid. – David Schwartz Sep 18 '12 at 01:01
  • 2
    You could just restart the daemon – Ben Lessani Sep 18 '12 at 08:06
  • from the memcached documentation: `This command does not pause the server, as it returns immediately. It does not free up or flush memory at all, it just causes all items to expire.` If you want to actually free it, you will have to restart the service. `sudo service memcached restart` – Ali Nov 04 '16 at 18:58

1 Answers1

4

Mark all items as stale (it will not clean the cache itself)

echo flush_all | telnet 127.0.0.1 11211

Perform dump, it will clean the stale items (but it may not deallocate memory)

/usr/share/memcached/scripts/memcached-tool 127.0.0.1:11211 dump > /dev/null

You can check the cache usage by

/usr/share/memcached/scripts/memcached-tool 127.0.0.1:11211 display

Tested on memcache 1.4.13

ziima
  • 141
  • 2