-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A bunch of minor performance optimizations #16335
Merged
Migaroez
merged 18 commits into
v13/dev
from
v13/hotfix/performance-optimizations-based-on-eu-data
Jun 3, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ee59368
Do not execute query if no macros found
bergmania 7b4581b
Request cache the permission lookup
bergmania 5d51d81
Unbreak change by adding obsolete ctor
bergmania 487f480
Clean up
bergmania e1e584b
Wrap indexing for delivery API in a scope
bergmania c2d1b7a
Do not ask options every time for the timeout, instead listen for upd…
bergmania 61908b4
Lookup content types once instead of one by one
bergmania 5c16cfb
Use TryGetValue instead
bergmania 07431e0
Do a distinct on user ids before building index, to avoid issue with …
bergmania 97d3e0e
Merge remote-tracking branch 'refs/remotes/origin/release/13.3' into …
bergmania f5a264a
Don't map ContentDto (it's unused)
kjac e9a4c02
Introduce request bound block editor element cache
kjac d357c59
Merge branch 'refs/heads/release/13.3' into v13/hotfix/performance-op…
bergmania 1c34218
Merge remote-tracking branch 'refs/remotes/origin/v13/hotfix/performa…
bergmania e5725eb
Merge branch 'refs/heads/v13/dev' into v13/hotfix/performance-optimiz…
bergmania 290a8fc
Merge branch 'refs/heads/v13/dev' into v13/hotfix/performance-optimiz…
bergmania a011e0f
Merge remote-tracking branch 'refs/remotes/origin/release/13.3' into …
bergmania e9617af
Merge remote-tracking branch 'refs/remotes/origin/v13/dev' into v13/h…
bergmania File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that we have a requestCache in a entity service.
Think it would be better to do something like the
BlockEditorElementTypeCache
introduced in this PR to separate the caching behavior from the actual retrieval from persistance.