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) {