private bool TryUpdateAndReleaseLockPrepare(object lockId, ISessionStateItemCollection data, int sessionTimeout, out string[] keyArgs, out object[] valueArgs)
{
keyArgs = null;
valueArgs = null;
if (data != null)
{
List <object> list = new List <object>();
ChangeTrackingSessionStateItemCollection sessionItems = (ChangeTrackingSessionStateItemCollection)data;
int noOfItemsRemoved = redisUtility.AppendRemoveItemsInList(sessionItems, list);
int noOfItemsUpdated = redisUtility.AppendUpdatedOrNewItemsInList(sessionItems, list);
keyArgs = new string[] { Keys.LockKey, Keys.DataKey, Keys.InternalKey };
valueArgs = new object[list.Count + 8]; // this +8 is for first wight values in ARGV that we will add now
valueArgs[0] = (lockId == null) ? "" : lockId;
valueArgs[1] = sessionTimeout;
valueArgs[2] = noOfItemsRemoved;
valueArgs[3] = 9; // In Lua index starts from 1 so first item deleted will be 9th.
valueArgs[4] = noOfItemsRemoved + 8; // index for last removed item
valueArgs[5] = noOfItemsUpdated;
valueArgs[6] = noOfItemsRemoved + 9; // first item updated will be next to last item removed
valueArgs[7] = list.Count + 8; // index for last item in list in LUA
// if nothing is changed in session then also execute update script to update session timeout
if (list.Count != 0)
{
list.CopyTo(valueArgs, 8);
}
return(true);
}
return(false);
}