-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ETag Concurrency #56
Comments
How would you get the Etag from the Get response? |
The ETag is available in the "_etag" property from the content returned by CosmosDB. Albeit, I have not tested with just a byte array response, but json serialization directly with the Cosmos SDK. So if it is present in that response, it would be up to the consumer to ensure they read the etag out of the content correctly. |
That's true but the So based on that public API surface, there is no way for you to know which was the Unless we start going over the |
Ah right - didn't notice the document is wrapped in a Only way I can think of without affective the APIs would be to do this via extension methods which have a different return type (and using internal methods which the extension calls into). |
Yeah, you'd have to instead of accessing IDistributedCache, you'd have to access CosmosCache. For example, if CosmosCache had an extension method called GetSoAndSo() that returned the current byte[] + the Headers (Etag actual value is returned on the Headers) it could work. Needs a bit of a think through because it would require 2 specialized flows (Read and Write) that are outside of the IDistributedCache API. This obviously is not accessible for ASP.NET Session because they use the HttpContext.Session object directly, no way to access the underlying CosmosCache. |
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 evenGet
)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:
CosmosDistributedCacheEntryOptions : DistributedCacheEntryOptions
and add ETag appropriate properties on there.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.
The text was updated successfully, but these errors were encountered: