现在,每当用户使用数据抓取器时,整个数据源都会被重新填充,这需要时间..
为什么使用缓存有一个快速而简单的原因? (我从来没用过它)...或者我应该只将eniter事物存储在Session对象中,并以某种方式检测是否已经进行了初始数据加载?
PersonBusiness pb = new PersonBusiness(new PersonRepository());
if (personFilter == null)
{
listPerson = pb.GetAllPersons(strServer, strAppPath);
}
lvPersons.DataSource = listPerson;
lvPersons.DataBind();
答案 0 :(得分:0)
这比我想象的要容易得多。我需要的只是几行,listview和分页工作..一个例外是当设置新的过滤器时你需要删除缓存
if (Cache.Get("Members") != null)
{
listPerson = (List<Person>)Cache.Get("Members");
}
else
{
if (personFilter == null)
{
listPerson = pb.GetAllPersons(strServer, strAppPath);
Cache.Insert("Members", listPerson, null, DateTime.Now.AddSeconds(60), TimeSpan.Zero);
}
else
{
listPerson = pb.GetSomePersons(strServer, strAppPath, personFilter.FirstName, personFilter.LastName, personFilter.State, personFilter.Company, personFilter.Committees, personFilter.IndType, personFilter.MemberType);
Cache.Insert("Members", listPerson, null, DateTime.Now.AddSeconds(60), TimeSpan.Zero);
}
}