Nette\Caching\Storages\FileStorage::readMetaAndLock PHP Method

readMetaAndLock() protected method

Reads cache data from disk.
protected readMetaAndLock ( $file, $lock ) : array | null
return array | null
    protected function readMetaAndLock($file, $lock)
    {
        $handle = @fopen($file, 'r+b');
        // @ - file may not exist
        if (!$handle) {
            return NULL;
        }
        flock($handle, $lock);
        $head = stream_get_contents($handle, self::META_HEADER_LEN);
        if ($head && strlen($head) === self::META_HEADER_LEN) {
            $size = (int) substr($head, -6);
            $meta = stream_get_contents($handle, $size, self::META_HEADER_LEN);
            $meta = unserialize($meta);
            $meta[self::FILE] = $file;
            $meta[self::HANDLE] = $handle;
            return $meta;
        }
        flock($handle, LOCK_UN);
        fclose($handle);
        return NULL;
    }