How to cache data in a MVC application

后端 未结 14 1273
鱼传尺愫
鱼传尺愫 2020-11-22 11:39

I have read lots of information about page caching and partial page caching in a MVC application. However, I would like to know how you would cache data.

In my scena

14条回答
  •  春和景丽
    2020-11-22 12:05

    I will say implementing Singleton on this persisting data issue can be a solution for this matter in case you find previous solutions much complicated

     public class GPDataDictionary
    {
        private Dictionary configDictionary = new Dictionary();
    
        /// 
        /// Configuration values dictionary
        /// 
        public Dictionary ConfigDictionary
        {
            get { return configDictionary; }
        }
    
        private static GPDataDictionary instance;
        public static GPDataDictionary Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new GPDataDictionary();
                }
                return instance;
            }
        }
    
        // private constructor
        private GPDataDictionary() { }
    
    }  // singleton
    

提交回复
热议问题