示例#1
0
        private RedisCacheConnectionSettings ReadConfiguration()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddEnvironmentVariables();

            var config         = builder.Build();
            var connectionInfo = new RedisCacheConnectionSettings
            {
                RedisCacheName     = config["RedisCacheName"],
                RedisCachePassword = config["RedisCachePassword"]
            };

            if (string.IsNullOrEmpty(connectionInfo.RedisCacheName))
            {
                builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");
                config         = builder.Build();
                connectionInfo = new RedisCacheConnectionSettings
                {
                    RedisCacheName     = config["RedisCacheName"],
                    RedisCachePassword = config["RedisCachePassword"]
                };
            }

            return(connectionInfo);
        }
示例#2
0
 public RedisConnect()
 {
     RedisConnection = ReadConfiguration();
 }