|
ASP.Net提供很好的缓存对象和页面的机制(System.Web.Caching)。 其中缓存对象是可以用在Web和WinForm程序里面的。 比如: public static void InitDropDownList(DropDownList ddl, string tableName, string valueField, string textField, int options, string selectedValue) { DataTable dt = null ; object o = SimpleCache.Get(tableName); if (o != null ) { dt = o as DataTable; } if (dt == null ) { ...... dt = _db.ExecQuery(sql); //cache it for 1 hour SimpleCache.Insert(tableName, dt, null , DateTime.Now.AddHours(1), SimpleCache.NoSlidingExpiration); }...
|