servicestack.redis不保存Dictionary属性

时间:2011-11-25 13:07:21

标签: c# .net redis servicestack

我有以下课程:

public class UserSettings : IMongoEntity
{
    [BsonId]
    public ObjectId _id { get; private set; }

    [BsonElement("Uid")]
    public ObjectId UserId { get; set; }


    private Dictionary<string, StatusImportance> _imp;

    protected Dictionary<string, StatusImportance> ImportanceCollection
    {
        get {    
            if(_imp == null)
                _imp = new Dictionary<string, StatusImportance>();
        return _imp;
        }
        set { _imp = value; }
    }
 }

我向Redis保存了一个具有多个对象的ImportanceCollection的类的对象。然后当我从缓存中再次获取它时为空。

我正在使用RedisClient作为ICacheClient。

任何想法?或者RedisClient不保存字典属性?

由于

1 个答案:

答案 0 :(得分:1)

ServiceStack's C# Redis Client使用ServiceStack's JsonSerializer,默认情况下仅序列化公共成员。