Method TryRefreshSessionAsync
TryRefreshSessionAsync(TSessionToken, SessionRecord, int, CancellationToken)
Updates the session that the specified session token belongs to with the values of refreshedSession, if its stored generation is
still expectedGeneration. Returns true if the session was updated, or false if it no longer
exists or its generation has changed.
Declaration
Task<bool> TryRefreshSessionAsync(TSessionToken sessionToken, SessionRecord refreshedSession, int expectedGeneration, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| TSessionToken | sessionToken | The token of the session to update. |
| SessionRecord | refreshedSession | The values to store: Device, IpAddress, RefreshedUtc, ExpiresUtc and Generation. Its CreatedUtc and IsPersistent are the stored values, which never change. |
| int | expectedGeneration | The generation the stored session must have for the update to be applied. |
| CancellationToken | cancellationToken | A token to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<bool> |
Remarks
The generation check and the update must be atomic, such as a single conditional update statement, so that only one of several concurrent updates
of the same generation succeeds. The generation of refreshedSession can be the same as expectedGeneration.