public class MyEntity
{
public string Att1 { get; set; }
public DateTime Att2 { get; set; }
public KeyValuePair Att3 { get; set; }
public Dictionary Att4 { get; set; }
}
var list = new List<MyEntity>(100);
//put to cache .....
var cached = RedisClient.Get<List<MyEntity>>(key) ; // take 9745.9745 ms
var raw = RedisClient.Get(key); //get raw of the same key just take < 10 ms
我应该使用 Json.net 进行 json 序列化并改用 RedisClient.Get 吗?
最佳答案
您可能会受到第一次缓存命中惩罚的影响。 将每个 API 的每次调用的第一次从计时中剔除。
RedisClient 使用下面的 JsonSerializer,它执行完全相同的操作,从 Redis 中提取字符串并调用 JsonSerializer 来反序列化该类型。
关于c# - RedisClient.Get<T> C# 与 ServiceStack.Redis 的性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13301334/