在大多数编程语言中,字典比散列表更受欢迎.这背后的原因是什么?
我有四个课程如下:
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(); …Run Code Online (Sandbox Code Playgroud) 我有一个有点复杂的权限系统,总共使用六个数据库表,为了加快它,我想将这些表缓存在内存中,而不是每次页面加载时都要访问数据库.
但是,我需要在添加新用户或更改权限时更新此缓存.我不确定如何在内存缓存中使用它,以及如何安全地更新它而不会在更新的同时访问它而不会引起问题
有没有人有一个如何做这样的事情的例子,或者能指出我正确的研究方向?