/// <summary> /// 添加缓存 /// </summary> /// <param name="key">缓存key 如:/a/b/c/d</param> /// <param name="value"></param> /// <param name="timeout">超时时间</param> /// <returns></returns> public void Add(string key, object value, DateTime timeout) { if (value == null) { // Debug.Assert(false); return; } _strategy.Add(key, value, timeout); }
/// <summary> /// 功能:设置永久缓存项(服务器上key存在就替换,不存在就添加) /// </summary> /// <param name="key">缓存键值</param> /// <param name="value">缓存值</param> /// <returns>是否设置成功</returns> public static bool Add(string key, object value) { bool blnSuccess = false; if (null != s_cacheStrategy) { string strKey = GlobalHelper.GetLowerString(key); try { blnSuccess = s_cacheStrategy.Add(strKey, value, s_cacheExpiration); } catch (Exception ex) { SysLogHelper.LogMessage("CacheHelper.Add", ex.Message, LogLevel.Error, WriteLogType.FileLog); } } return(blnSuccess); }
public void Add(string key, object value, CacheItemPriority scavengingPriority, ICacheItemRefreshAction refreshAction, params ICacheItemExpiration[] expirations) { cache.Add(key, value, scavengingPriority, refreshAction, expirations); }