I've done a bit of research on using session token in cosmosdb's dotnet v3 sdk, and so far I found these two links that give me some hints on how to use it: utilize-session-tokens and how-to-convert-session-token.
In our scenario, we would like to have strong consistency (but we don't want to use strong consistency for all data) if the update belongs to the same userId
, so that when one instance updates data under this user, everyone else will immediately see the result.
We'd also want to use cosmosdb as a lock for another scenario.
However, the links above only show how to reuse a token that was returned from creating a document. And I wonder if I can construct my own session token and use it for strong consistency.
For example, if I want to update the data under a specific userId
I would use {userId}:-1#1
as the session token. Would that be a valid way to use the session token? I'm also not sure what the fields pkrangeid, Version, GlobalLSN mean and what role they play when cosmosdb deals with consistency.
Thanks in advance!