Azure / Azure/Microsoft.Extensions.Caching.Cosmos
Support ETag Concurrency
- Dominant language
- C#
- Stars
- 55
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
This is to avoid race conditions for writing a cache value from two places with conflicting values.
**Describe the solution you'd like**
Add support for CosmosDBs etag concurrency on `Set` (and maybe even `Get`)
**Describe alternatives you've considered**
There is no 'true' alternative to fix this, as it would always require multiple cache reads or writes to accomplish, and without those being within a single transaction, there is no way to guarantee a race condition did not occur.
**Additional context**
Recommend solution:
1. Derive `CosmosDistributedCacheEntryOptions : DistributedCacheEntryOptions` and add ETag appropriate properties on there.
2. Set / Get implementation can test if the passed in value is that type, and change ETag request options to CosmosDB as appropriate.
This way there is no API change or breaking change for existing users. New usage just needs to use the new entry options type if they desire, but can continue to use the old type if they have no need for ETag.
Contributor guide
Research direction
Start by reading the existing Set and Get implementations and the DistributedCacheEntryOptions usage. Trace how Cosmos DB request options are built, then define how the proposed CosmosDistributedCacheEntryOptions should carry ETag behavior. Done means optional ETag concurrency is supported without changing behavior for existing callers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100