Merge remote-tracking branch 'origin/v11/dev' into v12/dev
This commit is contained in:
@@ -4,35 +4,88 @@ namespace Umbraco.Cms.Infrastructure.PublishedCache;
|
||||
|
||||
internal static class CacheKeys
|
||||
{
|
||||
public static string PublishedContentChildren(Guid contentUid, bool previewing) =>
|
||||
"NuCache.Content.Children[" + DraftOrPub(previewing) + ":" + contentUid + "]";
|
||||
public static string PublishedContentChildren(Guid contentUid, bool previewing)
|
||||
{
|
||||
if (previewing)
|
||||
{
|
||||
return "NuCache.Content.Children[D::" + contentUid + "]";
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static string DraftOrPub(bool previewing) => previewing ? "D:" : "P:";
|
||||
return "NuCache.Content.Children[P::" + contentUid + "]";
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static string LangId(string? culture)
|
||||
=> string.IsNullOrEmpty(culture) ? string.Empty : "-L:" + culture;
|
||||
public static string ContentCacheRoots(bool previewing)
|
||||
{
|
||||
if (previewing)
|
||||
{
|
||||
return "NuCache.ContentCache.Roots[D:]";
|
||||
}
|
||||
|
||||
public static string ContentCacheRoots(bool previewing) =>
|
||||
"NuCache.ContentCache.Roots[" + DraftOrPub(previewing) + "]";
|
||||
return "NuCache.ContentCache.Roots[P:]";
|
||||
}
|
||||
|
||||
public static string MediaCacheRoots(bool previewing) => "NuCache.MediaCache.Roots[" + DraftOrPub(previewing) + "]";
|
||||
public static string MediaCacheRoots(bool previewing)
|
||||
{
|
||||
if (previewing)
|
||||
{
|
||||
return "NuCache.MediaCache.Roots[D:]";
|
||||
}
|
||||
|
||||
return "NuCache.MediaCache.Roots[P:]";
|
||||
}
|
||||
|
||||
public static string PublishedContentAsPreviewing(Guid contentUid) =>
|
||||
"NuCache.Content.AsPreviewing[" + contentUid + "]";
|
||||
|
||||
public static string ProfileName(int userId) => "NuCache.Profile.Name[" + userId + "]";
|
||||
|
||||
public static string PropertyCacheValues(Guid contentUid, string typeAlias, bool previewing) =>
|
||||
"NuCache.Property.CacheValues[" + DraftOrPub(previewing) + contentUid + ":" + typeAlias + "]";
|
||||
public static string PropertyCacheValues(Guid contentUid, string typeAlias, bool previewing)
|
||||
{
|
||||
if (previewing)
|
||||
{
|
||||
return "NuCache.Property.CacheValues[D:" + contentUid + ":" + typeAlias + "]";
|
||||
}
|
||||
|
||||
return "NuCache.Property.CacheValues[P:" + contentUid + ":" + typeAlias + "]";
|
||||
}
|
||||
|
||||
// routes still use int id and not Guid uid, because routable nodes must have
|
||||
// a valid ID in the database at that point, whereas content and properties
|
||||
// may be virtual (and not in umbracoNode).
|
||||
public static string ContentCacheRouteByContent(int id, bool previewing, string? culture) =>
|
||||
"NuCache.ContentCache.RouteByContent[" + DraftOrPub(previewing) + id + LangId(culture) + "]";
|
||||
public static string ContentCacheRouteByContent(int id, bool previewing, string? culture)
|
||||
{
|
||||
if (string.IsNullOrEmpty(culture))
|
||||
{
|
||||
if (previewing)
|
||||
{
|
||||
return "NuCache.ContentCache.RouteByContent[D:" + id +"]";
|
||||
}
|
||||
|
||||
public static string ContentCacheContentByRoute(string route, bool previewing, string? culture) =>
|
||||
"NuCache.ContentCache.ContentByRoute[" + DraftOrPub(previewing) + route + LangId(culture) + "]";
|
||||
return "NuCache.ContentCache.RouteByContent[P:" + id + "]";
|
||||
}
|
||||
else if (previewing)
|
||||
{
|
||||
return "NuCache.ContentCache.RouteByContent[D:" + id + "-L:" + culture + "]";
|
||||
}
|
||||
return "NuCache.ContentCache.RouteByContent[P:" + id + "-L:" + culture + "]";
|
||||
}
|
||||
|
||||
public static string ContentCacheContentByRoute(string route, bool previewing, string? culture)
|
||||
{
|
||||
if (string.IsNullOrEmpty(culture))
|
||||
{
|
||||
if (previewing)
|
||||
{
|
||||
return "NuCache.ContentCache.ContentByRoute[D:" + route + "]";
|
||||
}
|
||||
|
||||
return "NuCache.ContentCache.ContentByRoute[P:" + route + "]";
|
||||
}
|
||||
else if (previewing)
|
||||
{
|
||||
return "NuCache.ContentCache.ContentByRoute[D:" + route + "-L:" + culture + "]";
|
||||
}
|
||||
|
||||
return "NuCache.ContentCache.ContentByRoute[P:" + route + "-L:" + culture + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,23 @@ public class NuCacheContentRepository : RepositoryBase, INuCacheContentRepositor
|
||||
| ContentCacheDataSerializerEntityType.Media
|
||||
| ContentCacheDataSerializerEntityType.Member);
|
||||
|
||||
if(contentTypeIds != null)
|
||||
// If contentTypeIds, mediaTypeIds and memberTypeIds are null, truncate table as all records will be deleted (as these 3 are the only types in the table).
|
||||
if ((contentTypeIds == null || !contentTypeIds.Any())
|
||||
&& (mediaTypeIds == null || !mediaTypeIds.Any())
|
||||
&& (memberTypeIds == null || !memberTypeIds.Any()))
|
||||
{
|
||||
if (Database.DatabaseType == DatabaseType.SqlServer2012)
|
||||
{
|
||||
Database.Execute($"TRUNCATE TABLE cmsContentNu");
|
||||
}
|
||||
|
||||
if (Database.DatabaseType == DatabaseType.SQLite)
|
||||
{
|
||||
Database.Execute($"DELETE FROM cmsContentNu");
|
||||
}
|
||||
}
|
||||
|
||||
if (contentTypeIds != null)
|
||||
{
|
||||
RebuildContentDbCache(serializer, _nucacheSettings.Value.SqlPageSize, contentTypeIds);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
|
||||
<ProjectReference Include="..\Umbraco.Infrastructure\Umbraco.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user