Common/DocumentResultList: Add caching
This commit is contained in:
@@ -6,6 +6,7 @@ Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Base.IDB
|
||||
Imports DigitalData.Modules.ZooFlow.Constants
|
||||
Imports DigitalData.Modules.Base
|
||||
Imports DigitalData.Modules.ZooFlow
|
||||
|
||||
Namespace DocumentResultList
|
||||
|
||||
@@ -14,29 +15,50 @@ Namespace DocumentResultList
|
||||
|
||||
Private ReadOnly Client As Client
|
||||
Private ReadOnly Mode As OperationMode
|
||||
Private ReadOnly User As DigitalData.Modules.ZooFlow.State.UserState
|
||||
Private ReadOnly User As State.UserState
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pMode As OperationMode, pClient As Client, pUser As DigitalData.Modules.ZooFlow.State.UserState)
|
||||
Private ReadOnly Cache As Cache
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pMode As OperationMode, pClient As Client, pUser As State.UserState)
|
||||
MyBase.New(pLogConfig)
|
||||
Client = pClient
|
||||
Mode = pMode
|
||||
User = pUser
|
||||
|
||||
' Set up cache with capacity of 100 MB
|
||||
Cache = New Cache(104_900_000)
|
||||
End Sub
|
||||
|
||||
Public Function Load(pObjectId As Long, pFullPath As String) As Document
|
||||
Public Sub Invalidate(pDocument As Document)
|
||||
Cache.Remove(pDocument)
|
||||
End Sub
|
||||
|
||||
Public Function Load(pObjectId As Long, pFullPath As String, Optional pForce As Boolean = False) As Document
|
||||
Dim oDocument As Document = Nothing
|
||||
|
||||
If Cache.Contains(pObjectId) And pForce = False Then
|
||||
Return Cache.Where(Function(doc) doc.Id = pObjectId).Single()
|
||||
End If
|
||||
|
||||
Select Case Mode
|
||||
Case OperationMode.NoAppServer
|
||||
Return Load_FromWindream(pObjectId, pFullPath)
|
||||
oDocument = Load_FromWindream(pObjectId, pFullPath)
|
||||
|
||||
Case OperationMode.WithAppServer
|
||||
Return Load_FromIDB(pObjectId)
|
||||
oDocument = Load_FromIDB(pObjectId)
|
||||
|
||||
Case OperationMode.ZooFlow
|
||||
Return Load_FromZooflow(pObjectId)
|
||||
oDocument = Load_FromZooflow(pObjectId)
|
||||
|
||||
Case Else
|
||||
Return Nothing
|
||||
oDocument = Nothing
|
||||
End Select
|
||||
|
||||
If oDocument IsNot Nothing Then
|
||||
Cache.Add(oDocument)
|
||||
End If
|
||||
|
||||
Return oDocument
|
||||
End Function
|
||||
|
||||
Private Function Load_FromWindream(pObjectId As Long, pFullPath As String) As Document
|
||||
|
||||
Reference in New Issue
Block a user