추가 내용 커밋

This commit is contained in:
김민서 2024-04-02 17:17:19 +09:00
parent eba597fb51
commit cdb167f19b
1 changed files with 56 additions and 0 deletions

View File

@ -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<object> value, params string[] keys)
{
foreach(var item in value)
{
SetList(item, keys);
}
}
public T GetList<T>(long index, params string[] keys)
{
if (local)
return JsonConvert.DeserializeObject<T>(listType[KeySet(keys)][(int)index]);
else
return JsonConvert.DeserializeObject<T>(db.ListGetByIndex(KeySet(keys), index));
}
public List<T> GetList<T>(params string[] keys)
{
List<T> result = new List<T>();
if (local)
{
List<string> strings = listType[KeySet(keys)];
foreach (var item in strings)
{
result.Add(JsonConvert.DeserializeObject<T>(item));
}
}
else
{
RedisValue[] strings = db.ListRange(KeySet(keys));
foreach (var item in strings)
{
result.Add(JsonConvert.DeserializeObject<T>(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)
{