private function safelyReadData($path)
    {
        $fp = fopen($path, 'r');

        $retries = 0;
        do {
            if ($retries > 0) {
                usleep(static::MS_BETWEEN_RETRIES * 1000); //100ms
            }

            $retries++;
        } while (!flock($fp, LOCK_SH | LOCK_NB) && $retries <= static::MAX_RETRIES);

        if ($retries == static::MAX_RETRIES) {
            return false;
        }

        $data = file_get_contents($path);

        flock($fp, LOCK_UN);
        fclose($fp);

        return $data;
    }
private function safelyReadData($path)
    {
        $fp = fopen($path, 'r');

        $retries = 0;
        do {
            if ($retries > 0) {
                usleep(static::MS_BETWEEN_RETRIES * 1000); //100ms
            }

            $retries++;
        } while (!flock($fp, LOCK_SH | LOCK_NB) && $retries <= static::MAX_RETRIES);

        if ($retries == static::MAX_RETRIES) {
            return false;
        }

        $data = file_get_contents($path);

        flock($fp, LOCK_UN);
        fclose($fp);

        return $data;
    }
private function safelyReadData ( $ path ) { $ fp = fopen ( $ path , 'r' ) ; $ retries = 0 ; do { if ( $ retries > 0 ) { usleep ( static :: MS_BETWEEN_RETRIES * 1000 ) ; //100ms } $ retries ++ ; } while ( ! flock ( $ fp , LOCK_SH | LOCK_NB ) && $ retries <= static :: MAX_RETRIES ) ; if ( $ retries == static :: MAX_RETRIES ) { return false ; } $ data = file_get_contents ( $ path ) ; flock ( $ fp , LOCK_UN ) ; fclose ( $ fp ) ; return $ data ; }
Safely read data from a file

@param string $path
@return mixed
Safely read data from a file