Skip to content

Instantly share code, notes, and snippets.

@mkevac
Created July 18, 2012 10:04
Show Gist options
  • Save mkevac/3135365 to your computer and use it in GitHub Desktop.
Save mkevac/3135365 to your computer and use it in GitHub Desktop.
<?php
if (!extension_loaded('pcntl')) {
if (!dl('pcntl.so')) {
Error::add(ER_ERR.'-xxxx-'.__CLASS__, 'unable to load pcntl extension', NULL, NULL, __LINE__);
}
}
for ($i = 0; $i < 20; $i++) {
$pid = pcntl_fork();
if ($pid == -1) {
die('Error creating child #'.$i."\n");
} elseif ($pid) {
$childs[$pid] = true;
} else {
$c = memcache_connect('laccess.ulan', 11811);
$f = fopen('/local/tmp/marko'.$i.'.tmp', 'w');
$users = array(0211861686);
for ($j = 0; $j < 500; $j++) {
$result = memcache_laccess_get($c, $users);
if (!is_array($result)) {
fwrite($f, 'error '.$j."\n");
continue;
}
fwrite($f, "ok ".$j."\n");
$users[] = 0211861686;
}
fclose($f);
exit(0);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment