/// <summary> /// Updates the session-item information in the session-state data store with values from the current request, and clears the lock on the data. /// </summary> /// <param name="context">The <see cref="T:System.Web.HttpContext"/> for the current request.</param><param name="id">The session identifier for the current request.</param><param name="item">The <see cref="T:System.Web.SessionState.SessionStateStoreData"/> object that contains the current session values to be stored.</param><param name="lockId">The lock identifier for the current request. </param><param name="newItem">true to identify the session item as a new item; false to identify the session item as an existing item.</param> public override void SetAndReleaseItemExclusive(HttpContext context, string id, SessionStateStoreData item, object lockId, bool newItem) { ISessionStateItemCollection sessionItems = null; if (item.Items.Count > 0) { sessionItems = item.Items; } var database = GetConnection().GetDatabase(); RedisSessionStateStore.Create(database, id, item.Timeout).Set(sessionItems); }
private SessionStateStoreData DoGet(HttpContext context, string id, bool exclusive, out bool locked, out TimeSpan lockAge, out object lockId, out SessionStateActions actionFlags) { locked = false; lockId = null; lockAge = TimeSpan.Zero; actionFlags = SessionStateActions.None; var database = GetConnection().GetDatabase(); var state = RedisSessionStateStore.Get(database, id); if (state == null) { return(null); } state.UpdateExpire(); return(CreateLegitStoreData(context, state.GetSessionStateItemCollection(), null, (int)state.Timeout.TotalMinutes)); }
/// <summary> /// Adds a new session-state item to the data store. /// </summary> /// <param name="context">The <see cref="T:System.Web.HttpContext"/> for the current request.</param><param name="id">The <see cref="P:System.Web.SessionState.HttpSessionState.SessionID"/> for the current request.</param><param name="timeout">The session <see cref="P:System.Web.SessionState.HttpSessionState.Timeout"/> for the current request.</param> public override void CreateUninitializedItem(HttpContext context, string id, int timeout) { var database = GetConnection().GetDatabase(); RedisSessionStateStore.Create(database, id, timeout); }
/// <summary> /// Deletes item data from the session data store. /// </summary> /// <param name="context">The <see cref="T:System.Web.HttpContext"/> for the current request.</param><param name="id">The session identifier for the current request.</param><param name="lockId">The lock identifier for the current request.</param><param name="item">The <see cref="T:System.Web.SessionState.SessionStateStoreData"/> that represents the item to delete from the data store.</param> public override void RemoveItem(HttpContext context, string id, object lockId, SessionStateStoreData item) { var database = GetConnection().GetDatabase(); RedisSessionStateStore.Delete(database, id); }