Persistence - cleanup

This commit is contained in:
Stephan
2017-07-11 16:29:44 +02:00
parent 5fe38d6aaf
commit 9619066a50
37 changed files with 241 additions and 276 deletions

View File

@@ -14,7 +14,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
// provides efficient database access for NuCache
class Database
{
public ContentNodeKit GetContentSource(IDatabaseUnitOfWork uow, int id)
public ContentNodeKit GetContentSource(IScopeUnitOfWork uow, int id)
{
var dto = uow.Database.Fetch<ContentSourceDto>(new Sql(@"SELECT
n.id Id, n.uniqueId Uid,
@@ -36,7 +36,7 @@ WHERE n.nodeObjectType=@objType AND n.id=@id
return dto == null ? new ContentNodeKit() : CreateContentNodeKit(dto);
}
public ContentNodeKit GetMediaSource(IDatabaseUnitOfWork uow, int id)
public ContentNodeKit GetMediaSource(IScopeUnitOfWork uow, int id)
{
// should be only 1 version for medias
@@ -58,7 +58,7 @@ WHERE n.nodeObjectType=@objType AND n.id=@id
// we want arrays, we want them all loaded, not an enumerable
public IEnumerable<ContentNodeKit> GetAllContentSources(IDatabaseUnitOfWork uow)
public IEnumerable<ContentNodeKit> GetAllContentSources(IScopeUnitOfWork uow)
{
return uow.Database.Query<ContentSourceDto>(new Sql(@"SELECT
n.id Id, n.uniqueId Uid,
@@ -80,7 +80,7 @@ ORDER BY n.level, n.sortOrder
", new { objType = Constants.ObjectTypes.DocumentGuid })).Select(CreateContentNodeKit);
}
public IEnumerable<ContentNodeKit> GetAllMediaSources(IDatabaseUnitOfWork uow)
public IEnumerable<ContentNodeKit> GetAllMediaSources(IScopeUnitOfWork uow)
{
// should be only 1 version for medias
@@ -100,7 +100,7 @@ ORDER BY n.level, n.sortOrder
", new { objType = Constants.ObjectTypes.MediaGuid })).Select(CreateMediaNodeKit);
}
public IEnumerable<ContentNodeKit> GetBranchContentSources(IDatabaseUnitOfWork uow, int id)
public IEnumerable<ContentNodeKit> GetBranchContentSources(IScopeUnitOfWork uow, int id)
{
return uow.Database.Query<ContentSourceDto>(new Sql(@"SELECT
n.id Id, n.uniqueId Uid,
@@ -123,7 +123,7 @@ ORDER BY n.level, n.sortOrder
", new { objType = Constants.ObjectTypes.DocumentGuid, /*id =*/ id })).Select(CreateContentNodeKit);
}
public IEnumerable<ContentNodeKit> GetBranchMediaSources(IDatabaseUnitOfWork uow, int id)
public IEnumerable<ContentNodeKit> GetBranchMediaSources(IScopeUnitOfWork uow, int id)
{
// should be only 1 version for medias
@@ -144,7 +144,7 @@ ORDER BY n.level, n.sortOrder
", new { objType = Constants.ObjectTypes.MediaGuid, /*id =*/ id })).Select(CreateMediaNodeKit);
}
public IEnumerable<ContentNodeKit> GetTypeContentSources(IDatabaseUnitOfWork uow, IEnumerable<int> ids)
public IEnumerable<ContentNodeKit> GetTypeContentSources(IScopeUnitOfWork uow, IEnumerable<int> ids)
{
return uow.Database.Query<ContentSourceDto>(new Sql(@"SELECT
n.id Id, n.uniqueId Uid,
@@ -166,7 +166,7 @@ ORDER BY n.level, n.sortOrder
", new { objType = Constants.ObjectTypes.DocumentGuid, /*id =*/ ids })).Select(CreateContentNodeKit);
}
public IEnumerable<ContentNodeKit> GetTypeMediaSources(IDatabaseUnitOfWork uow, IEnumerable<int> ids)
public IEnumerable<ContentNodeKit> GetTypeMediaSources(IScopeUnitOfWork uow, IEnumerable<int> ids)
{
// should be only 1 version for medias

View File

@@ -226,7 +226,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// before I read it? NO! because the WHOLE content tree is read-locked using WithReadLocked.
// don't panic.
private void LockAndLoadContent(Action<IDatabaseUnitOfWork> action)
private void LockAndLoadContent(Action<IScopeUnitOfWork> action)
{
_contentStore.WriteLocked(() =>
{
@@ -239,7 +239,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
});
}
private void LoadContentFromDatabaseLocked(IDatabaseUnitOfWork uow)
private void LoadContentFromDatabaseLocked(IScopeUnitOfWork uow)
{
// locks:
// contentStore is wlocked (1 thread)
@@ -259,7 +259,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
_logger.Debug<FacadeService>("Loaded content from database (" + sw.ElapsedMilliseconds + "ms).");
}
private void LoadContentFromLocalDbLocked(IDatabaseUnitOfWork uow)
private void LoadContentFromLocalDbLocked(IScopeUnitOfWork uow)
{
var contentTypes = _serviceContext.ContentTypeService.GetAll()
.Select(x => new PublishedContentType(PublishedItemType.Content, x));
@@ -296,7 +296,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
// _contentStore.Set(contentNode);
//}
private void LockAndLoadMedia(Action<IDatabaseUnitOfWork> action)
private void LockAndLoadMedia(Action<IScopeUnitOfWork> action)
{
_mediaStore.WriteLocked(() =>
{
@@ -309,7 +309,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
});
}
private void LoadMediaFromDatabaseLocked(IDatabaseUnitOfWork uow)
private void LoadMediaFromDatabaseLocked(IScopeUnitOfWork uow)
{
// locks & notes: see content
@@ -327,7 +327,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
_logger.Debug<FacadeService>("Loaded media from database (" + sw.ElapsedMilliseconds + "ms).");
}
private void LoadMediaFromLocalDbLocked(IDatabaseUnitOfWork uow)
private void LoadMediaFromLocalDbLocked(IScopeUnitOfWork uow)
{
var mediaTypes = _serviceContext.MediaTypeService.GetAll()
.Select(x => new PublishedContentType(PublishedItemType.Media, x));
@@ -1178,7 +1178,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
}
// assumes content tree lock
private void RebuildContentDbCacheLocked(IDatabaseUnitOfWork uow, int groupSize, IEnumerable<int> contentTypeIds)
private void RebuildContentDbCacheLocked(IScopeUnitOfWork uow, int groupSize, IEnumerable<int> contentTypeIds)
{
var contentTypeIdsA = contentTypeIds?.ToArray();
var contentObjectType = Guid.Parse(Constants.ObjectTypes.Document);
@@ -1249,7 +1249,7 @@ WHERE cmsContentNu.nodeId IN (
}
// assumes media tree lock
public void RebuildMediaDbCacheLocked(IDatabaseUnitOfWork uow, int groupSize, IEnumerable<int> contentTypeIds)
public void RebuildMediaDbCacheLocked(IScopeUnitOfWork uow, int groupSize, IEnumerable<int> contentTypeIds)
{
var contentTypeIdsA = contentTypeIds?.ToArray();
var mediaObjectType = Guid.Parse(Constants.ObjectTypes.Media);
@@ -1310,7 +1310,7 @@ WHERE cmsContentNu.nodeId IN (
}
// assumes member tree lock
public void RebuildMemberDbCacheLocked(IDatabaseUnitOfWork uow, int groupSize, IEnumerable<int> contentTypeIds)
public void RebuildMemberDbCacheLocked(IScopeUnitOfWork uow, int groupSize, IEnumerable<int> contentTypeIds)
{
var contentTypeIdsA = contentTypeIds?.ToArray();
var memberObjectType = Guid.Parse(Constants.ObjectTypes.Member);
@@ -1370,7 +1370,7 @@ WHERE cmsContentNu.nodeId IN (
}
// assumes content tree lock
private bool VerifyContentDbCacheLocked(IDatabaseUnitOfWork uow)
private bool VerifyContentDbCacheLocked(IScopeUnitOfWork uow)
{
// every published content item should have a corresponding row in cmsContentXml
// every content item should have a corresponding row in cmsPreviewXml
@@ -1401,7 +1401,7 @@ AND cmsContentNu.nodeId IS NULL;"
}
// assumes media tree lock
public bool VerifyMediaDbCacheLocked(IDatabaseUnitOfWork uow)
public bool VerifyMediaDbCacheLocked(IScopeUnitOfWork uow)
{
// every non-trashed media item should have a corresponding row in cmsContentXml
@@ -1431,7 +1431,7 @@ AND cmsContentNu.nodeId IS NULL
}
// assumes member tree lock
public bool VerifyMemberDbCacheLocked(IDatabaseUnitOfWork uow)
public bool VerifyMemberDbCacheLocked(IScopeUnitOfWork uow)
{
// every member item should have a corresponding row in cmsContentXml

View File

@@ -1699,7 +1699,7 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
}
// assumes content tree lock
private void RebuildContentXmlLocked(IDatabaseUnitOfWork unitOfWork, IContentRepository repository, int groupSize, IEnumerable<int> contentTypeIds)
private void RebuildContentXmlLocked(IScopeUnitOfWork unitOfWork, IContentRepository repository, int groupSize, IEnumerable<int> contentTypeIds)
{
var contentTypeIdsA = contentTypeIds?.ToArray();
var contentObjectType = Guid.Parse(Constants.ObjectTypes.Document);
@@ -1772,7 +1772,7 @@ WHERE cmsContentXml.nodeId IN (
}
// assumes content tree lock
private void RebuildPreviewXmlLocked(IDatabaseUnitOfWork unitOfWork, IContentRepository repository, int groupSize, IEnumerable<int> contentTypeIds)
private void RebuildPreviewXmlLocked(IScopeUnitOfWork unitOfWork, IContentRepository repository, int groupSize, IEnumerable<int> contentTypeIds)
{
var contentTypeIdsA = contentTypeIds?.ToArray();
var contentObjectType = Guid.Parse(Constants.ObjectTypes.Document);
@@ -1849,7 +1849,7 @@ WHERE cmsPreviewXml.nodeId IN (
}
// assumes media tree lock
public void RebuildMediaXmlLocked(IDatabaseUnitOfWork unitOfWork, IMediaRepository repository, int groupSize, IEnumerable<int> contentTypeIds)
public void RebuildMediaXmlLocked(IScopeUnitOfWork unitOfWork, IMediaRepository repository, int groupSize, IEnumerable<int> contentTypeIds)
{
var contentTypeIdsA = contentTypeIds?.ToArray();
var mediaObjectType = Guid.Parse(Constants.ObjectTypes.Media);
@@ -1920,7 +1920,7 @@ WHERE cmsContentXml.nodeId IN (
}
// assumes member tree lock
public void RebuildMemberXmlLocked(IDatabaseUnitOfWork unitOfWork, IMemberRepository repository, int groupSize, IEnumerable<int> contentTypeIds)
public void RebuildMemberXmlLocked(IScopeUnitOfWork unitOfWork, IMemberRepository repository, int groupSize, IEnumerable<int> contentTypeIds)
{
var contentTypeIdsA = contentTypeIds?.ToArray();
var memberObjectType = Guid.Parse(Constants.ObjectTypes.Member);
@@ -1989,7 +1989,7 @@ WHERE cmsContentXml.nodeId IN (
}
// assumes content tree lock
private static bool VerifyContentAndPreviewXmlLocked(IDatabaseUnitOfWork unitOfWork)
private static bool VerifyContentAndPreviewXmlLocked(IScopeUnitOfWork unitOfWork)
{
// every published content item should have a corresponding row in cmsContentXml
// every content item should have a corresponding row in cmsPreviewXml
@@ -2031,7 +2031,7 @@ AND cmsPreviewXml.nodeId IS NULL OR cmsPreviewXml.xml NOT LIKE '% key=""'
}
// assumes media tree lock
public bool VerifyMediaXmlLocked(IDatabaseUnitOfWork unitOfWork, IMediaRepository repository)
public bool VerifyMediaXmlLocked(IScopeUnitOfWork unitOfWork, IMediaRepository repository)
{
// every non-trashed media item should have a corresponding row in cmsContentXml
// and that row should have the key="..." attribute
@@ -2064,7 +2064,7 @@ AND cmsContentXml.nodeId IS NULL OR cmsContentXml.xml NOT LIKE '% key=""'
}
// assumes member tree lock
public bool VerifyMemberXmlLocked(IDatabaseUnitOfWork unitOfWork, IMemberRepository repository)
public bool VerifyMemberXmlLocked(IScopeUnitOfWork unitOfWork, IMemberRepository repository)
{
// every member item should have a corresponding row in cmsContentXml