/// <summary> /// SetAndReleaseItemExclusiveAsync saves the item to db and releases lock. /// </summary> /// <remarks> /// In this implementation, the lock is stored as a separate item in db. /// If the lock failed to release, db cleaning routine should remove it /// according to the timestamp and TTL values as soon as possible. /// </remarks> public override async Task SetAndReleaseItemExclusiveAsync( HttpContextBase context, string id, SessionStateStoreData item, object lockId, bool newItem, CancellationToken cancellationToken) { AssertIdValid(id); Trace.WriteLine($"SetAndReleaseItemExclusiveAsync. items.Dirty: {item.Items.Dirty}"); var state = item.ExtractDataForStorage(); try { await _store.WriteContents(context, id, state, false); } finally { if (!newItem) { await _store.TryReleaseLock(id, lockId); } } }