public static function getFastest($appkey, $hosts) { if ($hosts == null || count($hosts) == 0) { throw new Exception("Hosts cann't be null or size must greater than 0"); } if (isset(ApiUrlRespectUtils::$appkeyAndFasterHost[$appkey]) && count(array_diff($hosts, isset(ApiUrlRespectUtils::$appKeyAndHost[$appkey]) ? ApiUrlRespectUtils::$appKeyAndHost[$appkey] : null)) == 0) { return ApiUrlRespectUtils::$appkeyAndFasterHost[$appkey]; } else { $fastest = ApiUrlRespectUtils::getFastestRealTime($hosts); ApiUrlRespectUtils::$appKeyAndHost[$appkey] = $hosts; ApiUrlRespectUtils::$appkeyAndFasterHost[$appkey] = $fastest; return $fastest; } }