We have a .net core API, where we are using one singleton object to store some information. We registered that object as singleton (Dependency Injection) in configure method of pipeline.
Now We have a requirement where we need to reset that object (null or blank) and set it again in next request for that API. But as the application runs on Service fabric on multiple instances/nodes, How can we reset the singleton object of all the instances?
Then don't use a singleton. Register it as scoped, since that's the lifetime you now need. Also, even as a singleton, you still have an instance per app instance/node. There is no such thing as share objects between app instances.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.