【发布时间】:2013-02-06 14:52:43
【问题描述】:
我有以下四个课程:
public class Section
{
public int SectionId { get; set; }
public string Name { get; set; }
public string Title { get; set; }
public string MetaTag { get; set; }
public string MetaDescription { get; set; }
public string UrlSafe { get; set; }
public string Header { get; set; }
public string ImageName { get; set; }
}
public interface ISectionRepository
{
List<Section> GetAllSections();
}
public class SectionRepository : ISectionRepository
{
Context context = new Context();
public List<Section> GetAllSections()
{
return context.Sections.ToList();
}
}
public class SectionApplication
{
SectionRepository sectionRepo = new SectionRepository();
public List<Section> GetAllSections()
{
return sectionRepo.GetAllSections();
}
}
在我的控制器中,我有
public class SectionController : Controller
{
SectionApplication sectionApp = new SectionApplication();
public ActionResult Index()
{
return View(sectionApp.GetAllSections());
}
}
现在,我想在内存中缓存部分特定时间,以便从缓存中读取部分(如果存在),否则从数据库中读取。
【问题讨论】:
-
哪个组件适用于 DB?