Closed nitrogenium closed 2 years ago
Greetings again, thanks for your issue!
The singleton will persist during the HTTP request processing and will be re-created for the next request (you can test it with the multiple calling increment()
method in your view). Also, you can read this interesting article.
But, if you want to have a "true" singleton - you should make an instance of your container before the requests processing, e.g. put it into the warm
section in the configuration file:
diff --git a/config/roadrunner.php b/config/roadrunner.php
index 3ad3f8c..8cc3a88 100644
--- a/config/roadrunner.php
+++ b/config/roadrunner.php
@@ -80,6 +80,7 @@
'warm' => [
...Defaults::servicesToWarm(),
+ 'mc',
],
'clear' => [
This issue can be closed?
Thank you for your reply. No more questions. I'm even a little ashamed that I did not look in the Spiral\RoadRunnerLaravel\Worker.php - all the answers are there.
Thanks for the awesome package.
A clean installation of this repository, but:
.rr.local.yml
MyCounter.php
In AppServiceProvider
In welcome.blade.php
In the log file each request:
Obviously, the counter is reset every time. Why? What am I doing wrong?
What power kills my singleton "mc"?