Skip to content

Instantly share code, notes, and snippets.

@ctigeek
Created May 14, 2015 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ctigeek/145ace038a9be50e4e25 to your computer and use it in GitHub Desktop.
Save ctigeek/145ace038a9be50e4e25 to your computer and use it in GitHub Desktop.
Flush memcache from powershell...
function Clear-Memcache($server, $port = 11211)
{
$msg = [System.Text.Encoding]::ASCII.GetBytes("flush_all`r`nquit`r`n")
$c = New-Object System.Net.Sockets.TcpClient($server, $port)
$str = $c.GetStream()
$str.Write($msg, 0, $msg.Length)
$buf = New-Object System.Byte[] 4096
$count = $str.Read($buf, 0, 4096)
[System.Text.Encoding]::ASCII.GetString($buf, 0, $count)
$str.Close()
$c.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment