From cdb167f19b05d87a134207cd87af262f81ea9139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=84=9C?= Date: Tue, 2 Apr 2024 17:17:19 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=82=B4=EC=9A=A9=20?= =?UTF-8?q?=EC=BB=A4=EB=B0=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/System/Redis.cs | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/Server/System/Redis.cs b/Server/System/Redis.cs index 483208a..2e42b49 100644 --- a/Server/System/Redis.cs +++ b/Server/System/Redis.cs @@ -1,5 +1,7 @@ using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using StackExchange.Redis; +using static System.Formats.Asn1.AsnWriter; namespace Server.System { @@ -84,7 +86,61 @@ namespace Server.System db.ListRightPush(KeySet(keys), JsonConvert.SerializeObject(value)); } + public void SetList(List value, params string[] keys) + { + foreach(var item in value) + { + SetList(item, keys); + } + } + public T GetList(long index, params string[] keys) + { + if (local) + return JsonConvert.DeserializeObject(listType[KeySet(keys)][(int)index]); + else + return JsonConvert.DeserializeObject(db.ListGetByIndex(KeySet(keys), index)); + } + + public List GetList(params string[] keys) + { + List result = new List(); + if (local) + { + List strings = listType[KeySet(keys)]; + foreach (var item in strings) + { + result.Add(JsonConvert.DeserializeObject(item)); + } + } + else + { + RedisValue[] strings = db.ListRange(KeySet(keys)); + foreach (var item in strings) + { + result.Add(JsonConvert.DeserializeObject(item)); + } + } + return result; + } + + public void Setz(string value,double score,params string[] keys) + { + Setz(new rank(value, score), keys); + } + + public void Setz(rank rank, params string[] keys) + { + if (local) + { + + } + + else + { + db.SortedSetAdd(KeySet(keys), rank.value, rank.score); + } + } private string KeySet(string[] keys) {