Example #1
0
 /// <summary>
 /// 清楚所有缓存
 /// </summary>
 public static void ClearCache()
 {
     foreach (var item in CacheStore)
     {
         CacheStore.Remove(item.Key);
     }
 }
Example #2
0
        public JsonResult Delete(int id)
        {
            CacheStore.Remove <Tutor>(id.ToString());
            string message = $"User has been removed successfully!";

            return(Json(message, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        /// <summary>
        /// 删除key开头匹配缓存
        /// </summary>
        /// <param name="key">缓存Key</param>
        /// <returns>缓存对象</returns>
        public static IEnumerable <object> DeleteStartsWith(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return(null);
            }

            var _cacheList = new List <object>();

            foreach (var item in CacheStore)
            {
                if (item.Key.StartsWith(key, StringComparison.OrdinalIgnoreCase))
                {
                    _cacheList.Add(CacheStore.Remove(item.Key));
                }
            }

            return(_cacheList);
        }
Example #4
0
        public JsonResult AddEditDetails(Tutor model)
        {
            string status = string.Empty;

            if (ModelState.IsValid)
            {
                if (model.Id > 0)
                {
                    CacheStore.Remove <Tutor>(model.Id.ToString());
                    CacheStore.Add <Tutor>(model.Id.ToString(), model);
                    status = "updated";
                }
                else
                {
                    model.Id = ++Id;
                    CacheStore.Add(Id.ToString(), model);
                    status = "saved";
                }
            }
            string message = $"Tutor has been { status } successfully!";

            return(Json(message, JsonRequestBehavior.AllowGet));
        }
Example #5
0
 /// <summary>
 /// 删除缓存
 /// </summary>
 /// <param name="key">缓存Key</param>
 /// <returns>缓存对象</returns>
 public static object Delete(string key)
 {
     return(CacheStore.Remove(key));
 }
        public bool DeleteByID(int ID)
        {
            CacheStore.Remove(GetByID(ID));

            return(true);
        }