Created
June 14, 2020 09:44
-
-
Save TheBlackPlague/d3b40b2ff8327aec858c1e929af45681 to your computer and use it in GitHub Desktop.
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
<?php | |
foreach ($configuration->requestList as $request) { | |
$video = $request->video; | |
$endpoint = $request->endpoint; | |
$lowestLatency = $endpoint->dataCenterLatency; | |
$selectedCache = null; | |
/** | |
* @var int $id | |
* @var Cache $connectedCache | |
*/ | |
foreach ($endpoint->connectedCaches as $id => $connectedCache) { | |
$latency = $endpoint->connectedCachesLatency[$id]; | |
if ($latency < $lowestLatency && $connectedCache->canStore($video)) { | |
$lowestLatency = $latency; | |
$selectedCache = $connectedCache; | |
} | |
} | |
if ($selectedCache instanceof Cache) { | |
$selectedCache->store($video); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment