Skip to content

Commit

Permalink
Merge pull request #5822 from skamphuis/feature/5819-Improvements-Cac…
Browse files Browse the repository at this point in the history
…hing

Feature/5819 improvements caching
  • Loading branch information
valadas authored Oct 13, 2023
2 parents 7631f2c + 7bd3647 commit df634b6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
6 changes: 3 additions & 3 deletions DNN Platform/Library/Entities/Tabs/TabController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1394,9 +1394,9 @@ public TabInfo GetTab(int tabId, int portalId, bool ignoreCache)
// correctly, this may occurred when install is set up in web farm.
tab = CBO.FillObject<TabInfo>(this.dataProvider.GetTab(tabId));

// if tab is not null means that the cache doesn't update correctly, we need clear the cache
// and let it rebuild cache when request next time.
if (tab != null)
// if tab is not null, and it is for "portalId", that means that the cache doesn't update correctly,
// we need to clear the cache and let it rebuild cache when request next time.
if (tab != null && tab.PortalID == portalId)
{
this.ClearCache(tab.PortalID);
}
Expand Down
19 changes: 17 additions & 2 deletions DNN Platform/Modules/HTML/Components/WorkflowStateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,31 @@ namespace DotNetNuke.Modules.Html
public class WorkflowStateController
{
private const string WORKFLOWCACHEKEY = "Workflow{0}";
private const string WORKFLOWSCACHEKEY = "Workflows{0}";
private const int WORKFLOWCACHETIMEOUT = 20;

private const CacheItemPriority WORKFLOWCACHEPRIORITY = CacheItemPriority.Normal;

/// <summary>GetWorkFlows retrieves a collection of workflows for the portal.</summary>
/// <summary>GetWorkFlows retrieves a collection of workflows for the portal from the cache.</summary>
/// <param name="portalID">The ID of the Portal.</param>
/// <returns>An <see cref="ArrayList"/> of <see cref="WorkflowStateInfo"/> instances.</returns>
public ArrayList GetWorkflows(int portalID)
{
return CBO.FillCollection(DataProvider.Instance().GetWorkflows(portalID), typeof(WorkflowStateInfo));
var cacheKey = string.Format(WORKFLOWSCACHEKEY, portalID);
return CBO.GetCachedObject<ArrayList>(new CacheItemArgs(cacheKey, WORKFLOWCACHETIMEOUT, WORKFLOWCACHEPRIORITY, portalID), this.GetWorkflowsCallBack);
}

/// -----------------------------------------------------------------------------
/// <summary>
/// GetWorkflowsCallBack retrieves a collection of WorkflowStateInfo objects for the Portal from the database.
/// </summary>
/// <param name = "cacheItemArgs">Arguments passed by the GetWorkflowStates method.</param>
/// <returns>WorkflowStateInfo List.</returns>
/// -----------------------------------------------------------------------------
public ArrayList GetWorkflowsCallBack(CacheItemArgs cacheItemArgs)
{
var portalId = (int)cacheItemArgs.ParamList[0];
return CBO.FillCollection(DataProvider.Instance().GetWorkflows(portalId), typeof(WorkflowStateInfo));
}

/// <summary>GetWorkFlowStates retrieves a collection of WorkflowStateInfo objects for the Workflow from the cache.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Dnn.PersonaBar.UI.Services.DTO
using System.Runtime.Serialization;

[DataContract]
[Serializable]
public class FrameworkQueryDTO
{
[DataMember(Name = "UpToDate")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
namespace Dnn.PersonaBar.UI.Services.DTO
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;

using DotNetNuke.Security.Roles;

[DataContract]
[Serializable]
public class RoleGroupDto
{
/// <summary>Initializes a new instance of the <see cref="RoleGroupDto"/> class.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

namespace Dnn.PersonaBar.UI.Services.DTO
{
using System;
using System.Runtime.Serialization;

[DataContract]
[Serializable]
public class SuggestionDto
{
[DataMember(Name = "value")]
Expand Down

0 comments on commit df634b6

Please sign in to comment.