2006-11-22

 

Asp.Net2.0 物件Catch的應用

絕對時間快取
Cache.Insert("key", TextBox1.Text, Nothing, Now.AddSeconds(5), TimeSpan.Zero)
相對時間快取
Cache.Insert("key", TextBox1.Text, Nothing, DateTime.MaxValue, TimeSpan.FromSeconds(5))
相依Xml檔案
Cache.Insert("key", TextBox1.Text, New System.Web.Caching.CacheDependency(Server.MapPath("Books.xml")))
移除後回呼
Cache.Insert("key", TextBox1.Text, Nothing, Now.AddSeconds(5), TimeSpan.Zero, CacheItemPriority.Default, New CacheItemRemovedCallback(AddressOf RemovedCallback))

回呼函式範例
Public Sub RemovedCallback(ByVal k As String, ByVal v As Object, ByVal r As CacheItemRemovedReason)
Dim sw As New StreamWriter("c:\Log.txt")
sw.WriteLine("Cache(''" & k & "'') 被移除了, 原因是 : " & r.ToString)
sw.Close()
End Sub

Comments: 張貼留言



<< Home

This page is powered by Blogger. Isn't yours?