1

我有以下课程:

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; }
    }
 }

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

我正在使用 RedisClient 作为 ICacheClient。

有任何想法吗?还是 RedisClient 不保存字典属性?

谢谢

4

1 回答 1

1

ServiceStack 的 C# Redis 客户端使用ServiceStack 的 JsonSerializer,它默认只序列化公共成员。

于 2011-11-25T15:12:04.283 回答