Fix #5852: clear the cache after import content.

This commit is contained in:
Ben
2025-12-03 09:08:01 +08:00
parent 29b87f809f
commit 86a3f67871

View File

@ -1,3 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Oqtane.Infrastructure;
using Oqtane.Models;
using Oqtane.Modules.HtmlText.Repository;
@ -12,6 +15,7 @@ using Oqtane.Interfaces;
using System.Collections.Generic;
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
// ReSharper disable ConvertToUsingDeclaration
@ -23,15 +27,21 @@ namespace Oqtane.Modules.HtmlText.Manager
private readonly IHtmlTextRepository _htmlText;
private readonly IDBContextDependencies _DBContextDependencies;
private readonly ISqlRepository _sqlRepository;
private readonly ITenantManager _tenantManager;
private readonly IMemoryCache _cache;
public HtmlTextManager(
IHtmlTextRepository htmlText,
IDBContextDependencies DBContextDependencies,
ISqlRepository sqlRepository)
ISqlRepository sqlRepository,
ITenantManager tenantManager,
IMemoryCache cache)
{
_htmlText = htmlText;
_DBContextDependencies = DBContextDependencies;
_sqlRepository = sqlRepository;
_tenantManager = tenantManager;
_cache = cache;
}
public string ExportModule(Module module)
@ -71,6 +81,13 @@ namespace Oqtane.Modules.HtmlText.Manager
htmlText.ModuleId = module.ModuleId;
htmlText.Content = content;
_htmlText.AddHtmlText(htmlText);
//clear the cache for the module
var alias = _tenantManager.GetAlias();
if(alias != null)
{
_cache.Remove($"HtmlText:{alias.SiteKey}:{module.ModuleId}");
}
}
public bool Install(Tenant tenant, string version)