小编Dip*_*hta的帖子

HttpCache vs Singleton - MVC应用程序的最佳实践

我对HttpCache和Singleton方法的理解有点困惑.

我的应用程序使用Asp.net MVC和的情况是,我有一些数据列表,这将永远不会改变,有些数据可能很少改变.

我已经使用Singleton存储库为这种类型的数据开发和部署了应用程序.它表现很好.唯一的问题是,当罕见的情况发生时,我必须重新启动IIS才能生效.

什么是最好的解决方案.

单身实施

public class SingletonRepository : ISingletonRepository
    {
        private static SingletonRepository singleInstance;

        private readonly IStateRepository stateRepo;
        private readonly ICountryRepository countryRepo;
        private readonly ITDPaymentModeRepository paymentModeRepo;
        private readonly ITDPlanRepository planRepo;
        private readonly ITDOrderTypeRepository orderTypeRepo;
        private readonly IKeywordRepository keywordRepo;
        private readonly IAgencyRepository agencyRepo;

        private readonly IList<AT_STATE> lstState;
        private readonly IList<AT_COUNTRY> lstCountry;
        private readonly IList<TDPaymentMode> lstPaymentMode;
        private readonly IList<TDPlan> lstPlan;
        private readonly IList<TDOrderType> lstOrderType;
        private readonly IList<Keyword> lstKeyword;
        private readonly IList<Agency_MST> lstAgency;

        private SingletonRepository()
        {
            stateRepo = new StateRepository();
            countryRepo …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc singleton http-caching

8
推荐指数
1
解决办法
5148
查看次数

MVC应用程序的缓存和会话管理器的最佳实践

大师,

我们已经通过各种方式在过去的应用程序中实现了CacheManager和SessionManager,例如通过创建SessionHelper静态类和CacheHelper静态类.

虽然它运作良好,但我们缺乏一般化和全球化视角的能力.因此,对于新的临时开发,我们打算在灵活性和可扩展性方面实现这种一般实现的最佳实践.

请建议.

asp.net-mvc session caching

2
推荐指数
1
解决办法
6485
查看次数

C#通用接口将候选者列入白名单过滤

我对Generics非常陌生,并发现它在创建存储库时非常有用.我的问题必须是非常基本的水平.

假设,我已经声明了一个Generic接口

public interface IEFRepository<T> where T : class
{
    int Count { get; }
    bool Contains(T entity);
    IQueryable<T> GetAll();
    IQueryable<T> GetAll(string includeEntities);
    IQueryable<T> FindBy(Expression<Func<T, bool>> predicate, string includeEntities = "");
    T Add(T entity);
    T GetById(int id);
    void Delete(T entity);
    void Update(T entity);
    int ExecuteSQL(string commandText);
    void Delete(int id);
}
Run Code Online (Sandbox Code Playgroud)

现在,我可以通过任何实现此合同的类.但是我想限制它仅被我的Config文件中配置的白名单继承

例如.允许"人员|部门|员工".

c# generics

2
推荐指数
1
解决办法
219
查看次数

标签 统计

asp.net-mvc ×2

c# ×1

caching ×1

generics ×1

http-caching ×1

session ×1

singleton ×1