diff --git a/Server/System/Redis.cs b/Server/System/Redis.cs index fa50f1d..4c1a19d 100644 --- a/Server/System/Redis.cs +++ b/Server/System/Redis.cs @@ -1,5 +1,6 @@ using Newtonsoft.Json; using StackExchange.Redis; +using static Quartz.Logging.OperationName; namespace Server.System { @@ -14,7 +15,7 @@ namespace Server.System Dictionary> listType; Dictionary> zType; Dictionary> hashType; - public Redis(string host = "127.0.0.1", int port = 6379) + public Redis(string host = "127.0.0.1", int port = 6379, int db = 0) { if (host == "localhost") { @@ -27,7 +28,7 @@ namespace Server.System else { redis = ConnectionMultiplexer.Connect($"{host}:{port}"); - db = redis.GetDatabase(); + this.db = redis.GetDatabase(db); } } @@ -38,25 +39,25 @@ namespace Server.System Console.WriteLine("--------------------"); } - public void SetString(object value, params string[] keys) + public void SetString(string value, params string[] keys) { if (local) { if (stringType.ContainsKey(KeySet(keys))) - stringType[KeySet(keys)] = JsonConvert.SerializeObject(value); + stringType[KeySet(keys)] = value; else - stringType.Add(KeySet(keys), JsonConvert.SerializeObject(value)); + stringType.Add(KeySet(keys), value); } else db.StringSet(KeySet(keys), JsonConvert.SerializeObject(value)); } - public T GetString(params string[] keys) + public string GetString(params string[] keys) { if (local) - return JsonConvert.DeserializeObject(stringType[KeySet(keys)]); + return stringType[KeySet(keys)]; else - return JsonConvert.DeserializeObject(db.StringGet(key: KeySet(keys))); + return db.StringGet(key: KeySet(keys)); } public void SetList(T value, params string[] keys) diff --git a/Server/System/Statics.cs b/Server/System/Statics.cs index 75b1012..622f220 100644 --- a/Server/System/Statics.cs +++ b/Server/System/Statics.cs @@ -10,12 +10,13 @@ namespace Server.System public static readonly string SQL_URL = "Host=192.168.0.2;Port=5432;Username=manager;Password=Zn2zs558W5SdD8K;Database=project_thewar;"; public static readonly string EXCEL_SQL_URL = "Host=192.168.0.2;Port=5432;Username=manager;Password=Zn2zs558W5SdD8K;Database=project_thewar;"; public static readonly string remoteUrl = "https://manager:BQNl01bJJF0wn9R@gitea.pandoli365.com/Team.thewar/thewar_excel.git"; + public static readonly Redis redis = new Redis("192.168.1.2", 6379, 1); #elif LIVE public static readonly string SQL_URL = "Host=192.168.0.2;Port=5432;Username=manager;Password=Zn2zs558W5SdD8K;Database=project_thewar;"; public static readonly string EXCEL_SQL_URL = "Host=192.168.0.2;Port=5432;Username=manager;Password=Zn2zs558W5SdD8K;Database=project_thewar;"; public static readonly string remoteUrl = "https://manager:BQNl01bJJF0wn9R@gitea.pandoli365.com/Team.thewar/thewar_excel_live.git"; + public static readonly Redis redis = new Redis("192.168.1.2", 6379, 1); #endif - public static readonly Redis redis = new Redis("172.16.18.244", 48600); public static readonly string URL = "https://0.0.0.0:4860";