Exemple #1
0
 /// <summary>
 /// 不带缓存更新函数的调度机制
 /// </summary>
 /// <param name="key">键名</param>
 /// <param name="initValue">原来的数据</param>
 /// <param name="loadedValue">更新后的数据</param>
 /// <param name="cache">缓存对象</param>
 /// <param name="expire">更新时间</param>
 public virtual void ReloadCacheWithoutRemoveFunc(string key, object initValue, object loadedValue, Cache cache, DateTime expire)
 {
     if (cache != null)
     {
         if (loadedValue != null)
         {
             cache.Add(key, loadedValue, expire);
         }
         else
         {
             cache.Add(key, initValue, expire);
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// 正常更新机制
 /// </summary>
 /// <param name="key">键名</param>
 /// <param name="value">值</param>
 /// <param name="cache">缓存</param>
 /// <param name="expire">过期时间</param>
 /// <param name="cacheRemoveEvent">缓存删除回调事件</param>
 public virtual void SetCacheRefreshAfterLoad(string key, object value, Cache cache, DateTime expire, CacheItemRemovedHandler cacheRemoveEvent)
 {
     cache.Add(key, value, expire, cacheRemoveEvent);
 }
Exemple #3
0
 /// <summary>
 /// 异常更新机制
 /// </summary>
 /// <param name="key">键名</param>
 /// <param name="value">值</param>
 /// <param name="cache">缓存</param>
 /// <param name="cacheRemoveEvent">缓存删除回调事件</param>
 public virtual void SetCacheRefreshWhenFail(string key, object value, Cache cache, CacheItemRemovedHandler cacheRemoveEvent)
 {
     cache.Add(key, value, DateTime.Now.AddMinutes(1), cacheRemoveEvent);
 }
Exemple #4
0
 /// <summary>
 /// 缓存更新的调度机制
 /// </summary>
 /// <param name="key">键名</param>
 /// <param name="initValue">原来的数据</param>
 /// <param name="loadedValue">更新后的数据</param>
 /// <param name="cache">缓存对象</param>
 /// <param name="expire">更新时间</param>
 /// <param name="reason">缓存对象超时模式枚举</param>
 /// <param name="cacheReloadEvent">cache重载回调</param>
 public virtual void ReloadCache(string key, object initValue, object loadedValue, Cache cache, DateTime expire, CacheExpireModeEnum reason, CacheItemRemovedHandler cacheReloadEvent)
 {
     if (cache != null)
     {
         if (loadedValue != null)
         {
             SetCacheRefreshAfterLoad(key, loadedValue, cache, expire, cacheReloadEvent);
         }
         else
         {
             SetCacheRefreshWhenFail(key, initValue, cache, cacheReloadEvent);
         }
     }
 }