コード例 #1
0
ファイル: CacheItem.cs プロジェクト: dreign/Famliy.Finance
 /// <summary>
 /// 绝对时间点超时类构造函数
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存的对象</param>
 /// <param name="expire">绝对时间点</param>
 public CacheItem(string key, object value, DateTime expire)
 {
     this._key = key;
     this._value = value;
     this._expireMode = CacheExpireModeEnum.AbsoluteTimePoint;
     this._expire = expire;
     this._lastAccess = DateTime.Now;
     this._ttl = -1;
     this.OnCacheItemRemoved = null;
 }
コード例 #2
0
 /// <summary>
 /// 绝对时间点超时类构造函数
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存的对象</param>
 /// <param name="expire">绝对时间点</param>
 /// <param name="onCacheItemRemoved">对象被从缓存中移除时的回调函数</param>
 public CacheItem(string key, object value, DateTime expire, CacheItemRemovedHandler onCacheItemRemoved)
 {
     this._key                = key;
     this._value              = value;
     this._expireMode         = CacheExpireModeEnum.AbsoluteTimePoint;
     this._expire             = expire;
     this._lastAccess         = DateTime.Now;
     this._ttl                = -1;
     this.OnCacheItemRemoved += new CacheItemRemovedHandler(onCacheItemRemoved);
 }
コード例 #3
0
ファイル: CacheItem.cs プロジェクト: dreign/Famliy.Finance
 /// <summary>
 /// 时间间隔类构造函数
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存的对象</param>
 /// <param name="timeToLive">距最后一次访问的时间间隔(分钟)</param>
 /// <param name="onCacheItemRemoved">对象被从缓存中移除时的回调函数</param>
 public CacheItem(string key, object value, int timeToLive, CacheItemRemovedHandler onCacheItemRemoved)
 {
     this._key = key;
     this._value = value;
     this._expireMode = CacheExpireModeEnum.IntervalAfterLastAccess;
     this._expire = DateTime.Now.AddYears(100);
     this._lastAccess = DateTime.Now;
     this._ttl = timeToLive;
     this.OnCacheItemRemoved += new CacheItemRemovedHandler(onCacheItemRemoved);
 }
コード例 #4
0
 /// <summary>
 /// 时间间隔类构造函数
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存的对象</param>
 /// <param name="timeToLive">距最后一次访问的时间间隔(分钟)</param>
 /// <param name="onCacheItemRemoved">对象被从缓存中移除时的回调函数</param>
 public CacheItem(string key, object value, int timeToLive, CacheItemRemovedHandler onCacheItemRemoved)
 {
     this._key                = key;
     this._value              = value;
     this._expireMode         = CacheExpireModeEnum.IntervalAfterLastAccess;
     this._expire             = DateTime.Now.AddYears(100);
     this._lastAccess         = DateTime.Now;
     this._ttl                = timeToLive;
     this.OnCacheItemRemoved += new CacheItemRemovedHandler(onCacheItemRemoved);
 }
コード例 #5
0
 /// <summary>
 /// 依赖于外部对象类构造函数
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存的对象</param>
 /// <param name="dependency">依赖对象</param>
 /// <param name="onCacheItemRemoved">对象被从缓存中移除时的回调函数</param>
 public CacheItem(string key, object value, IDependency dependency, CacheItemRemovedHandler onCacheItemRemoved)
 {
     this._key                = key;
     this._value              = value;
     this._expireMode         = CacheExpireModeEnum.Depend;
     this._expire             = DateTime.Now.AddYears(100);
     this._lastAccess         = DateTime.Now;
     this._ttl                = -1;
     this._dependency         = dependency;
     this.OnCacheItemRemoved += new CacheItemRemovedHandler(onCacheItemRemoved);
 }
コード例 #6
0
ファイル: CacheItem.cs プロジェクト: dreign/Famliy.Finance
 /// <summary>
 /// 依赖于外部对象类构造函数
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存的对象</param>
 /// <param name="dependency">依赖对象</param>
 /// <param name="onCacheItemRemoved">对象被从缓存中移除时的回调函数</param>
 public CacheItem(string key, object value, IDependency dependency, CacheItemRemovedHandler onCacheItemRemoved)
 {
     this._key = key;
     this._value = value;
     this._expireMode = CacheExpireModeEnum.Depend;
     this._expire = DateTime.Now.AddYears(100);
     this._lastAccess = DateTime.Now;
     this._ttl = -1;
     this._dependency = dependency;
     this.OnCacheItemRemoved += new CacheItemRemovedHandler(onCacheItemRemoved);
 } 
コード例 #7
0
ファイル: CacheHelper.cs プロジェクト: dreign/Famliy.Finance
 /// <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);
         }
     }
 }
コード例 #8
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);
         }
     }
 }