public static ConnectionMultiplexer Connect(RedisConfiguration configuration)
        {

            string connectionString = configuration.ConnectionString;
            if (string.IsNullOrWhiteSpace(configuration.ConnectionString))
            {
                Func<RedisConfiguration, string> createConfigurationOptions = (config) =>
                {
                    var configurationOptions = new ConfigurationOptions()
                    {
                        AllowAdmin = config.AllowAdmin,
                        ConnectTimeout = config.ConnectionTimeout,
                        Password = config.Password,
                        Ssl = config.IsSsl,
                        SslHost = config.SslHost,
                        ConnectRetry = 10,
                        AbortOnConnectFail = false
                    };
                    foreach (var endpoint in configuration.Endpoints)
                    {
                        configurationOptions.EndPoints.Add(endpoint.Host, endpoint.Port);
                    }

                    return configurationOptions.ToString();
                };
                connectionString = createConfigurationOptions(configuration);
            }
            ConnectionMultiplexer connection;
            lock (connectLock)
            {
                if (!connections.TryGetValue(connectionString, out connection))
                {
                    var builder = new StringBuilder();
                    using (var log = new StringWriter(builder, CultureInfo.InvariantCulture))
                    {
                        connection = ConnectionMultiplexer.Connect(connectionString, log);
                    }

                    connection.ConnectionFailed += (sender, args) =>
                    {
                        connections.Remove(connectionString);
                    };

                    if (!connection.IsConnected)
                    {
                        throw new InvalidOperationException("Connection failed.\n" + builder.ToString());
                    }

                    connection.PreserveAsyncOrder = false;
                    connections.Add(connectionString, connection);
                }
            }

            return connection;
        }
 public static RedisConfiguration GetConfiguration()
 {
     List<ServerEndPoint> list = new List<ServerEndPoint>();
     var tempCon = redisConnectionString[1].Split(':');
     var host = tempCon[0];
     var port = int.Parse(tempCon[1]);
     list.Add(new ServerEndPoint(host, port));
     var configuration = new RedisConfiguration("RedisStackExchange", list);
     int database = 0;
     if (!int.TryParse(ConfigurationManager.AppSettings["redisDatabase"], out database))
         database = 0;
     configuration.Password = redisConnectionString[0];
     configuration.Database = database;
     return configuration;
 }