【发布时间】:2009-12-03 21:32:43
【问题描述】:
只是寻找此代码的代码审查。 ASP.net 缓存不是一个选项。静态列表将在每天获得超过 10K 页面浏览量并且可能有并发读取尝试的网站上被大量访问。在重建列表时重新启动应用程序时,我想知道是否有任何我可能忽略的问题?锁定列表是实例化的最佳实践吗?
public class MyClass
{
private static List<Entry> _listCache = null;
protected static List<Entry> ListCache
{
get
{
if (_listCache == null)
{
_listCache = new List<Entry>();
lock (_listCache)
{
//Add items to the list _listCache from XML file
}
}
return _listCache;
}
}
//....Other methods that work with the list
}
【问题讨论】: