public override void SetAndReleaseItemExclusive(HttpContext context,
string sessionId,
SessionStateStoreData item,
object lockId,
bool newItem)
{
string serialized = serialize(item.Items as SessionStateItemCollection);
Document newValues = new Document();
newValues[ATTRIBUTE_SESSION_ID] = GetHashKey(sessionId);
newValues[ATTRIBUTE_LOCKED] = false;
newValues[ATTRIBUTE_LOCK_ID] = null;
newValues[ATTRIBUTE_LOCK_DATE] = DateTime.Now;
newValues[ATTRIBUTE_EXPIRES] = DateTime.Now.Add(this._timeout);
newValues[ATTRIBUTE_FLAGS] = 0;
newValues[ATTRIBUTE_SESSION_ITEMS] = serialized;
newValues[ATTRIBUTE_RECORD_FORMAT_VERSION] = CURRENT_RECORD_FORMAT_VERSION;
if (newItem)
{
newValues[ATTRIBUTE_CREATE_DATE] = DateTime.Now;
this._table.PutItem(newValues);
}
else
{
Document expected = new Document();
expected[ATTRIBUTE_LOCK_ID] = lockId.ToString();
// Not really any reason the condition should fail unless we get in some sort of weird
// app pool reset mode.
try
{
this._table.UpdateItem(newValues, new UpdateItemOperationConfig() { Expected = expected });
}
catch (ConditionalCheckFailedException) { }
}
}