Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public async Task RebuildDatabaseCacheIfSerializerChangedAsync()
private Task PerformRebuild()
{
using ICoreScope scope = _coreScopeProvider.CreateCoreScope();
_databaseCacheRepository.Rebuild();
_databaseCacheRepository.Rebuild([], [], []);

// If the serializer type has changed, we also need to update it in the key value store.
var currentSerializerValue = _keyValueService.GetValue(NuCacheSerializerKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ public void Rebuild(
| ContentCacheDataSerializerEntityType.Media
| ContentCacheDataSerializerEntityType.Member);

// 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 contentTypeIds, mediaTypeIds and memberTypeIds are all non-null but empty,
// truncate the table as all records will be deleted (as these 3 are the only types in the table).
if (contentTypeIds is not null && contentTypeIds.Count == 0 &&
mediaTypeIds is not null && mediaTypeIds.Count == 0 &&
memberTypeIds is not null && memberTypeIds.Count == 0)
{
if (Database.DatabaseType == DatabaseType.SqlServer2012)
{
Expand Down Expand Up @@ -280,10 +281,15 @@ await Database.InsertOrUpdateAsync(
// assumes content tree lock
private void RebuildContentDbCache(IContentCacheDataSerializer serializer, int groupSize, IReadOnlyCollection<int>? contentTypeIds)
{
if (contentTypeIds is null)
{
return;
}

Guid contentObjectType = Constants.ObjectTypes.Document;

// remove all - if anything fails the transaction will rollback
if (contentTypeIds == null || contentTypeIds.Count == 0)
if (contentTypeIds.Count == 0)
{
// must support SQL-CE
Database.Execute(
Expand All @@ -310,7 +316,7 @@ SELECT id FROM umbracoNode

// insert back - if anything fails the transaction will rollback
IQuery<IContent> query = SqlContext.Query<IContent>();
if (contentTypeIds != null && contentTypeIds.Count > 0)
if (contentTypeIds.Count > 0)
{
query = query.WhereIn(x => x.ContentTypeId, contentTypeIds); // assume number of ctypes won't blow IN(...)
}
Expand Down Expand Up @@ -345,13 +351,17 @@ SELECT id FROM umbracoNode
}

// assumes media tree lock
private void RebuildMediaDbCache(IContentCacheDataSerializer serializer, int groupSize,
IReadOnlyCollection<int>? contentTypeIds)
private void RebuildMediaDbCache(IContentCacheDataSerializer serializer, int groupSize, IReadOnlyCollection<int>? contentTypeIds)
{
if (contentTypeIds is null)
{
return;
}

Guid mediaObjectType = Constants.ObjectTypes.Media;

// remove all - if anything fails the transaction will rollback
if (contentTypeIds is null || contentTypeIds.Count == 0)
if (contentTypeIds.Count == 0)
{
// must support SQL-CE
Database.Execute(
Expand All @@ -378,7 +388,7 @@ SELECT id FROM umbracoNode

// insert back - if anything fails the transaction will rollback
IQuery<IMedia> query = SqlContext.Query<IMedia>();
if (contentTypeIds is not null && contentTypeIds.Count > 0)
if (contentTypeIds.Count > 0)
{
query = query.WhereIn(x => x.ContentTypeId, contentTypeIds); // assume number of ctypes won't blow IN(...)
}
Expand All @@ -398,13 +408,17 @@ SELECT id FROM umbracoNode
}

// assumes member tree lock
private void RebuildMemberDbCache(IContentCacheDataSerializer serializer, int groupSize,
IReadOnlyCollection<int>? contentTypeIds)
private void RebuildMemberDbCache(IContentCacheDataSerializer serializer, int groupSize, IReadOnlyCollection<int>? contentTypeIds)
{
if (contentTypeIds is null)
{
return;
}

Guid memberObjectType = Constants.ObjectTypes.Member;

// remove all - if anything fails the transaction will rollback
if (contentTypeIds == null || contentTypeIds.Count == 0)
if (contentTypeIds.Count == 0)
{
// must support SQL-CE
Database.Execute(
Expand All @@ -431,7 +445,7 @@ SELECT id FROM umbracoNode

// insert back - if anything fails the transaction will rollback
IQuery<IMember> query = SqlContext.Query<IMember>();
if (contentTypeIds != null && contentTypeIds.Count > 0)
if (contentTypeIds.Count > 0)
{
query = query.WhereIn(x => x.ContentTypeId, contentTypeIds); // assume number of ctypes won't blow IN(...)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public async Task RebuildMemoryCacheByContentTypeAsync(IEnumerable<int> mediaTyp
public void Rebuild(IReadOnlyCollection<int> contentTypeIds)
{
using ICoreScope scope = _scopeProvider.CreateCoreScope();
_databaseCacheRepository.Rebuild(contentTypeIds.ToList());
_databaseCacheRepository.Rebuild(mediaTypeIds: contentTypeIds.ToList());

IEnumerable<Guid> mediaTypeKeys = contentTypeIds.Select(x => _idKeyMap.GetKeyForId(x, UmbracoObjectTypes.MediaType))
.Where(x => x.Success)
Expand Down