55 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C#
		
	
	
	
namespace langguanApi.Common.Redis
 | 
						|
{
 | 
						|
    public class RedisOptions
 | 
						|
    {
 | 
						|
        public static readonly RedisOptions Default = new RedisOptions();
 | 
						|
        public RedisOptions()
 | 
						|
        {
 | 
						|
            this.Server = null;
 | 
						|
            this.Port = 6379;
 | 
						|
            this.Password = null;
 | 
						|
            this.Key = null;
 | 
						|
            this.Index = 0;
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// redis 服务地址
 | 
						|
        /// </summary>
 | 
						|
        public string Server { get; set; }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// redis 端口
 | 
						|
        /// </summary>
 | 
						|
        public int Port { get; set; }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// redis 连接密码
 | 
						|
        /// </summary>
 | 
						|
        public string Password { get; set; }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 自定义Key
 | 
						|
        /// </summary>
 | 
						|
        public string Key { get; set; }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 默认数据库索引
 | 
						|
        /// </summary>
 | 
						|
        public int Index { get; set; }
 | 
						|
        public string Connection { get; set; }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 转换数据库连接字符串
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="node"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        public string GetConnect()
 | 
						|
        {
 | 
						|
            if (string.IsNullOrWhiteSpace(Password))
 | 
						|
                return $"{Server}";
 | 
						|
            else
 | 
						|
                return $"{Server},password={Password}";
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |