echo "--------begin get user info--------\n"; $total = $redis->llen('request_queue'); if ($total == 0) { echo "--------done--------\n"; break; } $current_count = $total <= $max_connect ? $total : $max_connect; for ($i = 1; $i <= $current_count; ++$i) { $pid = pcntl_fork(); if ($pid == -1) { echo "--------fork child process failed--------\n"; exit(0); } if (!$pid) { $startTime = microtime(); $tmp_redis = PRedis::getInstance(); $tmp_u_id = $tmp_redis->lpop('request_queue'); if (empty($tmp_redis->zscore('already_get_queue', $tmp_u_id))) { saveUserInfo($tmp_u_id); $user_info = User::info($tmp_u_id); $user_followees_count = $tmp_redis->hget($tmp_u_id, 'followees_count'); $user_followers_count = $tmp_redis->hget($tmp_u_id, 'followers_count'); if ($user_info['followees_count'] != $user_followees_count) { updateUserInfo($tmp_u_id); echo "--------start getting {$tmp_u_id}'s " . $user_info['followees_count'] . " followees user list--------\n"; $followee_users = getUserList($tmp_u_id, 'followees', $user_info['followees_count'], 1); $tmp_redis->set($tmp_u_id, 'followees_count', count($followee_users)); if (!empty($followee_users)) { foreach ($followee_users as $user) { $tmp_redis->lpush('request_queue', $user[3]); }