The object will add a file lock before writing and release it right after the
contents have been written. This can be used to prevent corruption of data
when multiple requests try to write to the same file at the same time.
/** * {@inheritdoc} */ public function load($path) { $yaml = $this->filesys->read($path); try { return $this->parser->parse($yaml); } catch (ParseException $e) { throw new LoadException($e->getMessage(), $e->getCode(), $e); } }
protected function generateDispatchData() { $data = $this->routeCollector->getData(); if ($this->cachePath !== null) { $filesys = new LockingFilesystem(); $php = '<?php return ' . var_export($data, true) . ";\n"; $filesys->write($this->cachePath, $php); } return $data; }