Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

c# - How to update properties in ASP.NET Core Service (DI)

I have the Chatbot, the data for the chatbot is stored in the Azure Cosmos DB. If I change the data in Cosmos DB, I have to restart my web app because the service used for fetching the data from Cosmos is registered in Startup.cs as Singleton.

So my requirement is to update the service properties (data) from Cosmos without restarting the app; also it should not lead to a deadlock.

Can anyone help me with the way to achieve this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

CosmosClient provides a client-side logical representation of the Azure Cosmos DB account. This client can be used to configure and execute requests in the Azure Cosmos DB database service.

CosmosClient is thread-safe. It's recommended to maintain a single instance of CosmosClient per lifetime of the application which enables efficient connection management and performance.

CosmosDB Client will get the data that is actually present in the database unless you are caching it. Moreover, make sure, you are using the right consistency level and redundancy.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...