public void Init(HttpApplication app) { if (!initialized) { lock (typeof(RedisSessionStateModule)) { if (!initialized) { redisConfig = RedisSessionStateConfiguration.GetConfiguration(); // Add event handlers. app.AcquireRequestState += new EventHandler(this.OnAcquireRequestState); app.ReleaseRequestState += new EventHandler(this.OnReleaseRequestState); app.EndRequest += new EventHandler(this.OnEndRequest); // Create a SessionIDManager. sessionIDManager = new SessionIDManager(); sessionIDManager.Initialize(); redisConnection = new RedisConnection(redisConfig.Host, redisConfig.Port); initialized = true; } } } }
/// <summary> /// Loads the current configuration. If no configuration has been supplied yet, /// the settings are initialized by <see cref="M:AngiesList.Redis.RedisSessionStateConfiguration.UseWebConfig">reading from web.config</see>. /// </summary> /// <returns></returns> public static RedisSessionStateConfiguration GetConfiguration() { if (RedisSessionStateConfiguration.Instance == null) { RedisSessionStateConfiguration.UseWebConfig(); } return(RedisSessionStateConfiguration.Instance); }
/// <summary> /// Configure the redis session state provider. Note this is global, /// and typically would be called using PreApplicationStartMethodAttribute /// (see http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx) /// </summary> /// <param name="config"></param> public static void Configure(Action <RedisSessionStateConfiguration> config) { if (RedisSessionStateConfiguration.Instance == null) { RedisSessionStateConfiguration.Instance = new RedisSessionStateConfiguration(); } config(RedisSessionStateConfiguration.Instance); }
public CompressedValueSerializer(IValueSerializer serializer) { if (serializer == null) throw new ArgumentNullException("serializer"); _serializer = serializer; _redisConfig = RedisSessionStateConfiguration.GetConfiguration(); }
public override void Initialize(string name, NameValueCollection config) { if (string.IsNullOrWhiteSpace(name)) { name = "AspNetSession"; } base.Initialize(name, config); this.redisConfig = RedisSessionStateConfiguration.GetConfiguration(); this.lockHashKey = name + ":LockedSessions"; }
public void Init(HttpApplication app) { if (this.initialized) { return; } lock (typeof(RedisSessionStateModule)) { if (this.initialized) { return; } this.redisConfig = RedisSessionStateConfiguration.GetConfiguration(); app.AcquireRequestState += new EventHandler(this.OnAcquireRequestState); app.ReleaseRequestState += new EventHandler(this.OnReleaseRequestState); app.EndRequest += new EventHandler(this.OnEndRequest); SessionStateSection sessionState = ConfigurationManager.GetSection("system.web/sessionState") as SessionStateSection; string sessionIdManagerType = sessionState?.SessionIDManagerType; ISessionIDManager sessionIdManager; if (string.IsNullOrEmpty(sessionIdManagerType)) { sessionIdManager = new SessionIDManager(); } else { Type type = Type.GetType(sessionIdManagerType, false); if (type != null) { sessionIdManager = Activator.CreateInstance(type) as ISessionIDManager ?? new SessionIDManager(); } else { sessionIdManager = new SessionIDManager(); } } this.sessionIDManager = sessionIdManager; this.sessionIDManager.Initialize(); this.redisConnection = new RedisConnection(this.redisConfig.Host, this.redisConfig.Port, -1, (string)null, int.MaxValue, false, 10000); this.initialized = true; } }
/// <summary> /// Configure the redis session state provider using the regular sessionState /// section in web.config. /// </summary> public static void UseWebConfig() { RedisSessionStateConfiguration.Configure((Action <RedisSessionStateConfiguration>)(x => x.LoadFromWebConfig())); }
public override void Initialize(string name, NameValueCollection config) { if (String.IsNullOrWhiteSpace(name)) { name = "AspNetSession"; } base.Initialize(name, config); this.redisConfig = RedisSessionStateConfiguration.GetConfiguration(); lockHashKey = name + ":LockedSessions"; }
/// <summary> /// Configure the redis session state provider. Note this is global, /// and typically would be called using PreApplicationStartMethodAttribute /// (see http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx) /// </summary> /// <param name="config"></param> public static void Configure(Action<RedisSessionStateConfiguration> config) { if (Instance == null) Instance = new RedisSessionStateConfiguration(); config.Invoke(Instance); }