/// <summary> /// 获取本地缓存 /// </summary> /// <param name="key"></param> /// <returns></returns> public override object Get(string key) { if (DoNet.Common.IO.PathMg.IsWeb) { return(HttpContext.Current.Cache[key]); } else { return(PoolCach.GetObject(key)); } }
/// <summary> /// 移除缓存 /// </summary> /// <param name="key"></param> public override void Remove(string key) { if (DoNet.Common.IO.PathMg.IsWeb) { HttpContext.Current.Cache.Remove(key); } else { PoolCach.ClearObject(key); } }
/// <summary> /// 插入本地缓存 /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <param name="tspan"></param> public override void Insert(string key, object value, TimeSpan tspan) { if (DoNet.Common.IO.PathMg.IsWeb) { HttpContext.Current.Cache.Insert(key, value, null, System.Web.Caching.Cache.NoAbsoluteExpiration, tspan); } else { PoolCach.UpdateObject(key, value, tspan); } }
/// <summary> /// 插入本地缓存 /// </summary> /// <param name="key"></param> /// <param name="value"></param> /// <returns></returns> public override void Insert(string key, object value) { if (DoNet.Common.IO.PathMg.IsWeb) { HttpContext.Current.Cache.Insert(key, value); } else { PoolCach.SetObject(key, value); } }
string _sSessionID = "";//缓存集合标识 public CacheMg(string SessionID) { _sSessionID = SessionID; if (!lSessionKeys.Contains(SessionID)) { lSessionKeys.Add(SessionID); } Dictionary <string, object> dic = PoolCach.GetObject(_sSessionID) as Dictionary <string, object>; if (dic == null) { dic = new Dictionary <string, object>(); PoolCach.UpdateObject(_sSessionID, dic); } }
/// <summary> /// 移除缓存集合 /// </summary> /// <param name="SessionID"></param> public static void RemoveSession(string SessionID) { lSessionKeys.Remove(SessionID); PoolCach.ClearObject(SessionID); }
public void Clear() { PoolCach.ClearObject(_sSessionID); }