我们在与我的应用程序数据库位于同一实例的数据库中拥有每晚更新的数据。因此,为了节省数据库调用,我想将此静态数据缓存到 List(Of MyObject) 中。从理论的角度来看,这个缓存的 List(Of ) 是否应该通过全局变量缓存在表示层代码中?它应该在 .DLL 的全局变量中吗?
我正在考虑 .DLL,因为我创建了一个服务层,它公开暴露给 GUI,并调用 .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
我会以最好的方式解决这个问题吗?