我們每晚都會在與應用程序數據庫位於同一個實例中的數據庫中更新數據。所以爲了節省數據庫調用,我想將這個靜態數據緩存到List(Of MyObject)中。從理論的角度來看,這個緩存的List(Of)應該通過全局變量緩存在表示層代碼中嗎?它應該在.DLL中的全局變量中嗎?WinForms應用程序數據緩存 - 要緩存哪個層?
我想在.DLL,因爲我創建了一個服務層,這是公開暴露在圖形用戶界面,使調用到.DLL裏面的數據訪問層:
Public Shared Function Search(ByVal criteria As Core.Other.Customer) As List(Of Core.Other.Customer)
' TODO: Check the customer cache to see if it has been populated yet. If not, populate it.
If 1 = 1 Then
' TODO: Variable "list" needs to be a global object in the DLL.
' For SO readers: Dal class declared Friend.
Dim list As List(Of Core.Other.Customer) = Dal.Search.Customers.GetCache()
End If
Dim results As New List(Of Core.Other.Customer)
' TODO: Find the relevant customers in the cache and add them to variable "results".
Return results
End Function
我要去關於這個我能做到的最好的方式?
一些用戶將通過VPN使用該應用程序,這可悲的是在公司中低於標準。需要2秒鐘的數據庫調用在VPN上需要10秒。我需要在腦海中進行一些優化。 – HardCode 2009-02-27 17:08:12