Faster full nucache table rebuild (#13501)
* SQL Server Truncate when full nucache SQL rebuild. * Optimize truncate for SQL Lite * Remove comment. * Use current DB Types * I added a couple of formatting changes. --------- Co-authored-by: georgebid <91198628+georgebid@users.noreply.github.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user