Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体,从缓存中
        /// </summary>
        public Model.detile GetModelByCache(string DetileID)
        {
            string CacheKey = "detileModel-" + DetileID;
            object objModel = DataCache.GetCache(CacheKey);

            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(DetileID);
                    if (objModel != null)
                    {
                        int ModelCache = ConfigHelper.GetConfigInt("ModelCache");
                        DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch {}
            }
            return((Model.detile)objModel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体,从缓存中
        /// </summary>
        public Model.view_querykeyword GetModelByCache()
        {
            //该表无主键信息,请自定义主键/条件字段
            string CacheKey = "view_querykeywordModel-";
            object objModel = DataCache.GetCache(CacheKey);

            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel();
                    if (objModel != null)
                    {
                        int ModelCache = ConfigHelper.GetConfigInt("ModelCache");
                        DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch {}
            }
            return((Model.view_querykeyword)objModel);
        }