Created
July 24, 2013 07:03
-
-
Save h2ero/6068579 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
/** | |
* PHP gen redis protocol function | |
* author: h2ero <[email protected]> | |
* date: 2013-07-24 15:01:42 | |
* useage: php gen_redis_proto.php | redis-cli --pipe | |
*/ | |
function gen_redis_proto() | |
{ | |
$CRLF = "\r\n"; | |
$args = func_get_args(); | |
$proto = '*'.count($args).$CRLF; | |
foreach ($args as $arg) { | |
$proto .= '$'.strlen($arg).$CRLF; | |
$proto .= $arg.$CRLF; | |
} | |
return $proto; | |
} | |
for ($i = 0; $i < 1000000; $i++) { | |
echo gen_redis_proto("SET", "MYKEY$i", "VALUE$i"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment