/// <summary> /// Helper method which uses the RedisConnectionConfig properties to get the correct RedisConnectionWrapper /// given an HttpContext /// </summary> /// <param name="context">The httpcontext of the current request</param> /// <returns> /// A RedisConnectionWrapper object which can be used to get an StackExchange.Redis IDatabase instance /// for communicating with Redis /// </returns> public static RedisConnectionWrapper RedisConnWrapperFromContext(HttpContextBase context) { if (RedisConnectionConfig.GetSERedisServerConfigDbIndex != null) { Tuple <string, int, ConfigurationOptions> connData = RedisConnectionConfig.GetSERedisServerConfigDbIndex(context); return(new RedisConnectionWrapper( connData.Item1, connData.Item2, connData.Item3)); } else if (RedisConnectionConfig.GetSERedisServerConfig != null) { KeyValuePair <string, ConfigurationOptions> connData = RedisConnectionConfig.GetSERedisServerConfig(context); return(new RedisConnectionWrapper( connData.Key, connData.Value)); } #pragma warning disable 0618 else if (RedisConnectionConfig.GetRedisServerAddress != null) { return(new RedisConnectionWrapper( RedisConnectionConfig.GetRedisServerAddress(context))); } #pragma warning restore 0618 throw new ConfigurationErrorsException( "RedisSessionProvider.Config.RedisConnectionWrapper.GetSERedisServerConfig delegate not set " + "see project page at: github.com/welegan/RedisSessionProvider#configuring-your-specifics"); }
private static RedisConnectionWrapper GetConnectionWrapperConfiguredByIdServerDatabase(HttpContextBase context) { if (RedisConnectionConfig.GetSERedisServerConfigDbIndex == null) { return(null); } var connData = RedisConnectionConfig.GetSERedisServerConfigDbIndex(context); return(new RedisConnectionWrapper(connData.Item1, connData.Item2, connData.Item3)); }