File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
components/dependency_injection Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -468,6 +468,14 @@ serves at dumping the compiled container::
468468 file_put_contents($file, $dumper->dump());
469469 }
470470
471+
472+ .. tip ::
473+
474+ Call to `file_put_contents ` is not atomic. When generating container in
475+ a production environment with multiple concurrent requests, use `dumpFile `
476+ from `component-filesystem ` instead. This generates file in tmp and moves it
477+ to its destination only once it's fully written to.
478+
471479``ProjectServiceContainer `` is the default name given to the dumped container
472480class. However, you can change this with the ``class `` option when you
473481dump it::
@@ -559,6 +567,11 @@ for these resources and use them as metadata for the cache::
559567
560568 require_once $file;
561569 $container = new MyCachedContainer();
570+
571+ .. note ::
572+
573+ Using `$containerConfigCache->write ` also makes sure that
574+ the file write operation is atomic.
562575
563576Now the cached dumped container is used regardless of whether debug mode
564577is on or not. The difference is that the ``ConfigCache `` is set to debug
You can’t perform that action at this time.
0 commit comments