使用微软企业库-缓存
using System.Data;
//
using Microsoft.Practices.EnterpriseLibrary.Caching;
using Microsoft.Practices.EnterpriseLibrary.Caching.Expirations;
/// <summary>
///使用微软企业库-缓存
/// </summary>
public class EnterpriseCache
{
    //实例化微软企业库缓存管理类
    CacheManager cm = CacheFactory.GetCacheManager();
    //1、放入缓存
    public void CachAllDept()
    {
        IDataReader dr = (new EnterpriseDA()).GetAllDeptReturnDRbySql();
        cm.Add("AllDept", dr);
        //cm.Remove();
    }
    //2、从缓存中获取
    public string[] GetAllDeptReturnDR()
    {
        string[] arr = { "" };
        IDataReader dr = (IDataReader)cm.GetData("AllDept");
        if (dr != null)
        {
            int i = 0;
            while (dr.Read())
            {
                arr[i] = dr.GetValue(2).ToString();
                i++;
            }
        }
        return arr;
    }
}
 
                    
                     
                    
                 
                    
                 
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号