In Flushing memcached servers the easy way I highlighted a way to flush a memcached server without restarting it:
$ echo ”flush_all” | nc localhost 11211
However I almost never use the actual shell version of this, mostly I do the equivalent in Ruby by opening up a socket and communicating through that. Here’s a simple example:
socket = TCPSocket.new( '127.0.0.1', 11211 )
socket.write( "flush_allrn" )
result = socket.recv(2)
puts "Success!" if result == 'OK'