c# - RedisClient.Get<T> C# 与 ServiceStack.Redis 的性能

标签 c# redis json.net servicestack

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/

相关文章:

c# - WCF 数据服务更新返回 401-未经授权 : Access is denied due to invalid credentials

caching - Xorm Redis 缓存似乎无法正常工作

c# - 在运行时编译代码时添加额外的引用

C# 将 DataGridView 绑定(bind)到 Hashtable

c# - 当按下 "New"按钮时,有没有办法调用一些服务器端代码?

redis - redis 是否串行处理命令?

amazon-ec2 - Redis:Amazon EC2 与 Elasticache

c# - 使用 json.net 反序列化空正则表达式属性

c# - 单击选择性粘贴时如何在 visual studio 2012 中显示 "paste Json class"?

c# - 这个线程安全吗?多次命中断点