cosmosdb-repo | Repository pattern for Cosmos DB | Database library
kandi X-RAY | cosmosdb-repo Summary
kandi X-RAY | cosmosdb-repo Summary
Simple repository pattern for Cosmos DB.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of cosmosdb-repo
cosmosdb-repo Key Features
cosmosdb-repo Examples and Code Snippets
Community Discussions
Trending Discussions on cosmosdb-repo
QUESTION
I was tinkering with repository pattern for CosmosDB. I have modified the code to have a singleton CosmosDb DocumentClient
. Every instance of the repository is making network calls to fetch Database
& DocumentCollection
. So I want to know whether it is right to cache the Database
& DoumentCollection
objects, as in my case I will only have one collection & one database.
ANSWER
Answered 2018-Mar-06 at 12:26A lot of "demo" code you see is "incorrect" as it is a few lines of code to create or read something from CosmosDB. This will work fine without a singleton due to low volumes. Scale a simple operation up to a high volume multi threaded application and you will see problems.
In order to avoid issues, you should only create one DocumentClient
per CosmosDB instance and one DocumentCollection
per collection in your database otherwise you will incur the additional overhead of unnecessary instantiation and under high load you will experience socket exhaustion.
We mark ours as volatile (C#) too:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install cosmosdb-repo
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page