/// <summary> /// 获取缓存 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="ItmeName"></param> /// <param name="id"></param> /// <param name="type"></param> /// <returns></returns> public static CacheReturnData <T> GetCache <T>(string key) { CacheReturnData <T> cd = new CacheReturnData <T>(); try { CacheModule cm = new CacheModule(); if (cm.Exists(key)) { cd.data = cm.Get <T>(key); cd.reult = true; } else { cd.reult = false; cd.data = default(T); } } catch { cd.reult = false; cd.data = default(T); } return(cd); }
/// <summary> /// 设置缓存 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="data"></param> /// <param name="ItmeName"></param> /// <param name="id"></param> /// <param name="type"></param> /// <returns></returns> public static CacheReturnData <T> SetCache <T>(T data, string key) { CacheReturnData <T> cd = new CacheReturnData <T>(); try { CacheModule cm = new CacheModule(); cd.reult = cm.Set(key, data); cd.data = data; } catch { cd.reult = false; cd.data = default(T); } return(cd); }
public static CacheReturnData <Dictionary <string, string> > ServerModuleInfo() { CacheReturnData <Dictionary <string, string> > cd = new CacheReturnData <Dictionary <string, string> >(); try { CacheModule cm = new CacheModule(); cd.data = cm.ServerInfo(); cd.reult = true; } catch { cd.reult = false; cd.data = new Dictionary <string, string>(); } return(cd); }
public static CacheReturnData <long> TryDelCache(string pattrm) { CacheReturnData <long> cd = new CacheReturnData <long>(); try { CacheModule cm = new CacheModule(); cd.data = cm.Delete(pattrm); cd.reult = true; } catch { cd.reult = false; cd.data = 0; } return(cd); }
/// <summary> /// 删除缓存 /// </summary> /// <param name="ItmeName"></param> /// <param name="id"></param> /// <param name="type"></param> /// <returns></returns> public static CacheReturnData <long> DelCache(string key) { CacheReturnData <long> cd = new CacheReturnData <long>(); try { CacheModule cm = new CacheModule(); cd.data = cm.Delete(key); cd.reult = true; } catch { cd.reult = false; cd.data = -1; } return(cd); }
/// <summary> /// 缓存统计 /// </summary> /// <returns></returns> public static CacheReturnData <long> CacheCount() { CacheReturnData <long> cd = new CacheReturnData <long>(); try { CacheModule cm = new CacheModule(); cd.data = cm.KeysNum(); cd.reult = true; } catch { cd.reult = false; cd.data = 0; } return(cd); }