V15: Add custom serializer for hybrid cache (#17727)

* Add custom serializer

* Add migration to rebuild cache

* Rename migration namespace to 15.1

* Also clear media cache

* Remove failed cache items

* Refactor to only use keys for document cache repository

---------

Co-authored-by: nikolajlauridsen <nikolajlauridsen@protonmail.ch>
This commit is contained in:
Nikolaj Geisle
2024-12-06 13:20:57 +01:00
committed by GitHub
parent ce6d4c34e2
commit 1c859e75ca
11 changed files with 123 additions and 102 deletions

View File

@@ -189,30 +189,6 @@ AND cmsContentNu.nodeId IS NULL
return count == 0;
}
public async Task<ContentCacheNode?> GetContentSourceAsync(int id, bool preview = false)
{
Sql<ISqlContext>? sql = SqlContentSourcesSelect()
.Append(SqlObjectTypeNotTrashed(SqlContext, Constants.ObjectTypes.Document))
.Append(SqlWhereNodeId(SqlContext, id))
.Append(SqlOrderByLevelIdSortOrder(SqlContext));
ContentSourceDto? dto = await Database.FirstOrDefaultAsync<ContentSourceDto>(sql);
if (dto == null)
{
return null;
}
if (preview is false && dto.PubDataRaw is null && dto.PubData is null)
{
return null;
}
IContentCacheDataSerializer serializer =
_contentCacheDataSerializerFactory.Create(ContentCacheDataSerializerEntityType.Document);
return CreateContentNodeKit(dto, serializer, preview);
}
public async Task<ContentCacheNode?> GetContentSourceAsync(Guid key, bool preview = false)
{
Sql<ISqlContext>? sql = SqlContentSourcesSelect()
@@ -292,25 +268,6 @@ AND cmsContentNu.nodeId IS NULL
public IEnumerable<Guid> GetDocumentKeysByContentTypeKeys(IEnumerable<Guid> keys, bool published = false)
=> GetContentSourceByDocumentTypeKey(keys, Constants.ObjectTypes.Document).Where(x => x.Published == published).Select(x => x.Key);
public async Task<ContentCacheNode?> GetMediaSourceAsync(int id)
{
Sql<ISqlContext>? sql = SqlMediaSourcesSelect()
.Append(SqlObjectTypeNotTrashed(SqlContext, Constants.ObjectTypes.Media))
.Append(SqlWhereNodeId(SqlContext, id))
.Append(SqlOrderByLevelIdSortOrder(SqlContext));
ContentSourceDto? dto = await Database.FirstOrDefaultAsync<ContentSourceDto>(sql);
if (dto is null)
{
return null;
}
IContentCacheDataSerializer serializer =
_contentCacheDataSerializerFactory.Create(ContentCacheDataSerializerEntityType.Media);
return CreateMediaNodeKit(dto, serializer);
}
public async Task<ContentCacheNode?> GetMediaSourceAsync(Guid key)
{
Sql<ISqlContext>? sql = SqlMediaSourcesSelect()