Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
将配置信息放到XML中,利用cache放到内存中,同时增加一文件依赖,保证配置文件改变时自动删除缓存。
private DataTable GetData()
{
DataTable tableData = new DataTable();
if (Cache["data"] == null)
{
DataSet ds = new DataSet();
string filePath = Server.MapPath("~/XMLFile.xml");
ds.ReadXml(filePath);
tableData = ds.Tables[0];
CacheDependency cdy = new CacheDependency(filePath);
Cache.Insert("data", tableData, cdy);
}
else
{
tableData = (DataTable)Cache["data"];
}
return tableData;
}
——-
<?xml version="1.0" encoding="utf-8" ?>
<book>
<item>
<bookName>算法设计</bookName>
<author>清华</author>
</item>
<item>
<bookName>高级数据库技术</bookName>
<author>中山大学</author>
</item>
</book>