只是寻找这段代码的代码审查.ASP.net Cache不是一个选项.静态列表将在每天获得超过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
}
Run Code Online (Sandbox Code Playgroud)