如果我缓存 List<string>
并执行 Get 我得到了四个项目及其值(如预期)。如果我缓存 List<PortedNumberCollection>
并执行 Get- 我得到了正确数量的项目,但所有值(MSISDN、RoutingLabel、RouteAction)都为空,为什么?
[DataContract]
public class PortedNumberCollection
{
[DataMember]
public Int64 PortedID;
[DataMember]
public string MSISDN;
[DataMember]
public string RoutingLabel;
[DataMember]
public string RouteAction;
}
string host = "localhost";
RedisClient redi = new RedisClient(host);
//List<string> PorCol = new List<string> {
// "Hi there",
// "Hello world",
// "Many name is",
// "Uh, my name is"
//};
List<PortedNumberCollection> PorCol = MobileDAL.ReadPortedNumberCollection();
redi.Set("PorColCache", PorCol);
//List<string> msgs = redi.Get<List<string>>("PorColCache");
List<PortedNumberCollection> msgs = redi.Get<List<PortedNumberCollection>>("PorColCache");
最佳答案
您可以尝试添加 {get;设置;} 在字段之后?像 public string RouteAction {get;设置;
关于c# - 缓存列表 <T> 返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20223033/