1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /* 作者: 季健国
- * 创建时间: 2012/7/19 21:47:20
- *
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Web;
- namespace Ant.Service.Common
- {
- public interface ICache
- {
- /// <summary>
- /// 获取全局应用缓存
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- object GetApplicationCache(string key);
- /// <summary>
- /// 设置全局应用缓存
- /// </summary>
- /// <param name="key"></param>
- /// <param name="obj"></param>
- void SetApplicationCache(string key, object obj);
- /// <summary>
- /// 删除全局应用缓存
- /// </summary>
- /// <param name="key"></param>
- void RemoveApplicationCache(string key);
- }
- /// <summary>
- /// 全局应用缓存
- /// </summary>
- public class ApplicationCache:ICache
- {
- #region ICache 成员
- public object GetApplicationCache(string key)
- {
- return HttpContext.Current.Application[key];
- }
- public void SetApplicationCache(string key, object obj)
- {
- HttpContext.Current.Application.Add(key, obj);
- }
- public void RemoveApplicationCache(string key)
- {
- HttpContext.Current.Application.Remove(key);
- }
- #endregion
- }
- }
|