protected function readCacheFile($cacheEntryPathAndFilename, $offset = null, $maxlen = null)
{
for ($i = 0; $i < 3; $i++) {
$data = false;
try {
$file = fopen($cacheEntryPathAndFilename, 'rb');
if ($file === false) {
continue;
}
if (flock($file, LOCK_SH) !== false) {
if ($offset !== null) {
fseek($file, $offset);
}
$data = fread($file, $maxlen !== null ? $maxlen : filesize($cacheEntryPathAndFilename) - (int) $offset);
flock($file, LOCK_UN);
}
fclose($file);
} catch (\Exception $e) {
}
if ($data !== false) {
return $data;
}
usleep(rand(10, 500));
}
return $data;
}