|
- using System;
- using System.Text;
-
- namespace HealthMonitor.Model.Config
- {
-
-
-
- public class RedisConfig
- {
- public string Server { get; set; } = string.Empty;
-
-
-
- public string Password { get; set; } = string.Empty;
-
-
-
- public int? DefaultDatabase { get; set; }
-
-
-
- public bool? AsyncPipeline { get; set; }
-
-
-
- public int? Poolsize { get; set; }
-
-
-
- public int? IdleTimeout { get; set; }
-
-
-
- public int? ConnectTimeout { get; set; }
-
-
-
- public int? SyncTimeout { get; set; }
-
-
-
- public int? Preheat { get; set; }
-
-
-
- public bool? AutoDispose { get; set; }
-
-
-
- public bool? Ssl { get; set; }
-
-
-
- public bool? Testcluster { get; set; }
-
-
-
- public int? Tryit { get; set; }
-
-
-
- public string? Name { get; set; }
-
-
-
- public string? Prefix { get; set; }
-
- public override string ToString()
- {
- if (string.IsNullOrWhiteSpace(Server)) throw new ArgumentNullException(nameof(Server));
- var sb = new StringBuilder(Server);
- if (!string.IsNullOrWhiteSpace(Password)) sb.Append($",password={Password}");
- if (DefaultDatabase.HasValue) sb.Append($",defaultDatabase={DefaultDatabase}");
- if (AsyncPipeline.HasValue) sb.Append($",asyncPipeline={AsyncPipeline}");
- if (Poolsize.HasValue) sb.Append($",poolsize={Poolsize}");
- if (IdleTimeout.HasValue) sb.Append($",idleTimeout={IdleTimeout}");
- if (ConnectTimeout.HasValue) sb.Append($",connectTimeout={ConnectTimeout}");
- if (SyncTimeout.HasValue) sb.Append($",syncTimeout={0}");
- if (Preheat.HasValue) sb.Append($",preheat={Preheat}");
- if (AutoDispose.HasValue) sb.Append($",autoDispose={AutoDispose}");
- if (Ssl.HasValue) sb.Append($",ssl={Ssl}");
- if (Testcluster.HasValue) sb.Append($",testcluster={Testcluster}");
- if (Tryit.HasValue) sb.Append($",tryit={Tryit}");
- if (!string.IsNullOrWhiteSpace(Name)) sb.Append($",name={Name}");
- if (!string.IsNullOrWhiteSpace(Prefix)) sb.Append($",prefix={Prefix}");
-
- return sb.ToString();
- }
- }
- }
|