예제 #1
0
 /// <summary>
 /// 添加缓存对象
 /// 根据依赖对象计算是否超时
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存对象</param>
 /// <param name="dependency">依赖对象</param>
 public void Add(string key, object value, IDependency dependency)
 {
     try
     {
         CacheItem item = new CacheItem(key, value, dependency);
         this.AddItem(item);
     }
     catch
     {
     }
 }
예제 #2
0
 /// <summary>
 /// 添加缓存对象
 /// 根据依赖对象计算是否超时
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存对象</param>
 /// <param name="dependency">依赖对象</param>
 /// <param name="onCacheItemRemoved">缓存对象被移除时的回调函数</param>
 public void Add(string key, object value, IDependency dependency, CacheItemRemovedHandler onCacheItemRemoved)
 {
     try
     {
         CacheItem item = new CacheItem(key, value, dependency, onCacheItemRemoved);
         this.AddItem(item);
     }
     catch
     {
     }
 }
예제 #3
0
 /// <summary>
 /// 添加缓存对象
 /// 根据绝对时间点计算是否超时
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存对象</param>
 /// <param name="expire">绝对时间点</param>
 /// <param name="onCacheItemRemoved">缓存对象被移除时的回调函数</param>
 public void Add(string key, object value, DateTime expire, CacheItemRemovedHandler onCacheItemRemoved)
 {
     try
     {
         CacheItem item = new CacheItem(key, value, expire, onCacheItemRemoved);
         this.AddItem(item);
     }
     catch
     {
     }
 }
예제 #4
0
 /// <summary>
 /// 添加缓存对象
 /// 根据绝对时间点计算是否超时
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存对象</param>
 /// <param name="expire">绝对时间点</param>
 public void Add(string key, object value, DateTime expire)
 {
     try
     {
         CacheItem item = new CacheItem(key, value, expire);
         this.AddItem(item);
     }
     catch
     {
     }
 }
예제 #5
0
 /// <summary>
 /// 添加缓存对象
 /// 根据距最后访问时间间隔计算是否超时
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存对象</param>
 /// <param name="timeToLive">距最后访问的时间间隔(分钟)</param>
 public void Add(string key, object value, int timeToLive)
 {
     try
     {
         CacheItem item = new CacheItem(key, value, timeToLive);
         this.AddItem(item);
     }
     catch 
     {
     }
 }
예제 #6
0
 /// <summary>
 /// 添加缓存对象
 /// 缺省添加函数,根据距最后访问的时间间隔计算是否超时,缺省超时时间60分钟
 /// </summary>
 /// <param name="key">键值</param>
 /// <param name="value">缓存对象</param>
 public void Add(string key, object value)
 {
     try
     {
         CacheItem item = new CacheItem(key, value, 60);
         this.AddItem(item);
     }
     catch 
     {
     }
 }
예제 #7
0
 /// <summary>
 /// 添加CacheItem
 /// </summary>
 /// <param name="item">缓存项</param>
 private void AddItem(CacheItem item)
 {
     this._objectRepository[item.Key] = item;
     if (OnCacheAdded != null) OnCacheAdded(item.Key);
 }