-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A bunch of minor performance optimizations (#16335)
* Do not execute query if no macros found * Request cache the permission lookup * Unbreak change by adding obsolete ctor * Clean up * Wrap indexing for delivery API in a scope * Do not ask options every time for the timeout, instead listen for updates * Lookup content types once instead of one by one * Use TryGetValue instead * Do a distinct on user ids before building index, to avoid issue with more than 2100 parameters * Don't map ContentDto (it's unused) * Introduce request bound block editor element cache --------- Co-authored-by: kjac <kja@umbraco.dk>
- Loading branch information
Showing
21 changed files
with
210 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Umbraco.Infrastructure/Cache/PropertyEditors/BlockEditorElementTypeCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Umbraco.Cms.Core.Models; | ||
using Umbraco.Cms.Core.Services; | ||
using Umbraco.Extensions; | ||
|
||
namespace Umbraco.Cms.Core.Cache.PropertyEditors; | ||
|
||
internal sealed class BlockEditorElementTypeCache : IBlockEditorElementTypeCache | ||
{ | ||
private readonly IContentTypeService _contentTypeService; | ||
private readonly AppCaches _appCaches; | ||
|
||
public BlockEditorElementTypeCache(IContentTypeService contentTypeService, AppCaches appCaches) | ||
{ | ||
_contentTypeService = contentTypeService; | ||
_appCaches = appCaches; | ||
} | ||
|
||
public IEnumerable<IContentType> GetAll(IEnumerable<Guid> keys) | ||
{ | ||
// TODO: make this less dumb; don't fetch all elements, only fetch the items that aren't yet in the cache and amend the cache as more elements are loaded | ||
|
||
const string cacheKey = $"{nameof(BlockEditorElementTypeCache)}_ElementTypes"; | ||
IEnumerable<IContentType>? cachedElements = _appCaches.RequestCache.GetCacheItem<IEnumerable<IContentType>>(cacheKey); | ||
if (cachedElements is null) | ||
{ | ||
cachedElements = _contentTypeService.GetAllElementTypes(); | ||
_appCaches.RequestCache.Set(cacheKey, cachedElements); | ||
} | ||
|
||
return cachedElements.Where(elementType => keys.Contains(elementType.Key)); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/Umbraco.Infrastructure/Cache/PropertyEditors/IBlockEditorElementTypeCache.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Umbraco.Cms.Core.Models; | ||
|
||
namespace Umbraco.Cms.Core.Cache.PropertyEditors; | ||
|
||
public interface IBlockEditorElementTypeCache | ||
{ | ||
IEnumerable<IContentType> GetAll(IEnumerable<Guid> keys); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.