add global cache

This commit is contained in:
updsv7
2026-04-16 16:01:47 +09:00
parent c39b8da85e
commit b0c6ec6baa
5 changed files with 111 additions and 74 deletions

View File

@@ -0,0 +1,58 @@
' ============================================================
' Modele Name: GlobalCache
' Modele Desc: Global Cache Module, Shared caches across all worksheets
' ============================================================
' M1 cache - used by M2_Kukan_detail
Public m1Cache As Object
' Z1 cache - used by M1_Kukan
Public z1Cache As Object
' Refresh M1 cache - called when M1 data changes
Public Sub RefreshM1Cache()
' Clear existing cache first to avoid memory leak
Set m1Cache = Nothing
On Error GoTo RefreshError
Set m1Cache = LoadLookup("M1", keyCol:=3, valueCols:=Array(3, 4, 5, 6, 7, 9, 12), startRow:=7)
On Error GoTo 0
If m1Cache Is Nothing Or m1Cache.Count = 0 Then
Err.Raise 1001, "RefreshM1Cache", "M1 reference data is empty"
End If
Exit Sub
RefreshError:
Err.Raise 1002, "RefreshM1Cache", "Failed to load M1 lookup cache: " & Err.Description
End Sub
' Clear M1 cache - called when M1 data is cleared
Public Sub ClearM1Cache()
Set m1Cache = Nothing
End Sub
' Refresh Z1 cache - called when Z1 data changes
Public Sub RefreshZ1Cache()
' Clear existing cache first to avoid memory leak
Set z1Cache = Nothing
On Error GoTo RefreshError
Set z1Cache = LoadLookup("Z1", keyCol:=3, valueCols:=Array(4), startRow:=7)
On Error GoTo 0
If z1Cache Is Nothing Or z1Cache.Count = 0 Then
Err.Raise 1001, "RefreshZ1Cache", "Z1 reference data is empty"
End If
Exit Sub
RefreshError:
Err.Raise 1002, "RefreshZ1Cache", "Failed to load Z1 lookup cache: " & Err.Description
End Sub
' Clear Z1 cache - called when Z1 data is cleared
Public Sub ClearZ1Cache()
Set z1Cache = Nothing
End Sub