memcachedに保存しようとしてIEnumerable<T>
いますが、 のインスタンスしか正常に保存できませんでしたT
。
memcached に列挙を格納する別のコードはありますか?
public IEnumerable<UsContentView> GetContentViewByUserId(int userId)
{
Expire("contentViewUserId_" + userId);
var result = Memcached.Get<IEnumerable<UsContentView>>("contentViewUserId_" + userId);
if (result == null)
{
result = db.UsContentViews.Where(m => m.UserID == userId).OrderBy(m => m.ArticleId).Distinct();
var arr = result.ToArray();
var arrList = arr.ToList();
//store it in the cache, with the key
StoreList(arrList, "contentViewUserId_" + userId);
MemoryStream mem = new MemoryStream();
BinaryFormatter b = new BinaryFormatter();
try
{
b.Serialize(mem, result);
}
catch (EntitySqlException ex)
{
throw new ApplicationException("The object query failed", ex);
}
catch (EntityCommandExecutionException ex)
{
throw new ApplicationException("The object query failed", ex);
}
catch (SerializationException ex)
{
throw new ApplicationException("The object graph could not be serialized", ex);
}
}
return result;
}