Created
May 14, 2015 20:01
-
-
Save ctigeek/145ace038a9be50e4e25 to your computer and use it in GitHub Desktop.
Flush memcache from powershell...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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