We are running a vary large DNN installation with over 300 child portals. We are running with DNN v4.9.4.
We have experienced a few problems recently with the amount of data that certain core DNN functions require from the database.
The worse offender at the moment is the GetAllTabs function. I found one fix in the DNN Gemini that has made a huge difference - : http://support.dotnetnuke.com/issue/ViewIssue.aspx
However we are all seeing this procedure being called from the GetPortalDictionary in the PortalController. What I am struggling to understand though are the repeated calls to the SP.
The function tries to get the PortalDictionary from the Cache. If it cannot find it, the PortalDictionary is recreated by calling the GetAllTabs SP and once complete, it stores it in cache. I recently amended the function to write to the event log every time it calls the GetAllTabs function.
What I am seeing is repeated calls to the GetAllTabs.
My question is why would this happen?
Why is the code not finding the PortalDictionary in Cache (shown in blue below)?
Here is the code I am referring to:
Public Shared Function GetPortalDictionary() As Dictionary(Of Integer, Integer)
Dim key As String = DataCache.PortalDictionaryCacheKey
' retrieve from cache
Dim portalDic As Dictionary(Of Integer, Integer) = TryCast(DataCache.GetCache(key), Dictionary(Of Integer, Integer))
If portalDic Is Nothing Then
' create dictionary
portalDic = New Dictionary(Of Integer, Integer)
' portal dictionary caching settings
Dim timeOut As Int32 = DataCache.PortalDictionaryTimeOut * Convert.ToInt32(Common.Globals.PerformanceSetting)
' if caching is disabled, do not make this database call as it is too expensive on every request
If timeOut > 0 Then
' get all tabs
'My code to write to event Log Dim PS As Entities.Portals.PortalSettings PS = GetHostPortalSettings() Dim ctlrEventLog As New DotNetNuke.Services.Log.EventLog.EventLogController ctlrEventLog.AddLog("Calling GetAllTabs ", "", PS, -1, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.ADMIN_ALERT)
Dim intField As Integer
Dim dr As IDataReader = DataProvider.Instance().GetAllTabs()
Try
While dr.Read
' add to dictionary
portalDic(Convert.ToInt32(Null.SetNull(dr("TabID"), intField))) = Convert.ToInt32(Null.SetNull(dr("PortalID"), intField))
End While
Catch exc As Exception
LogException(exc)
Finally
' close datareader
If Not dr Is Nothing Then
dr.Close()
End If
End Try
' cache portal dictionary
DataCache.SetCache(key, portalDic, TimeSpan.FromMinutes(timeOut), True)
End If
End If
Return portalDic
End Function