Skip to content

Hybrid Cache: Element cache#22369

Merged
lauraneto merged 34 commits into
v18/devfrom
v18/feature/element-cache
Apr 20, 2026
Merged

Hybrid Cache: Element cache#22369
lauraneto merged 34 commits into
v18/devfrom
v18/feature/element-cache

Merge branch 'v18/dev' into v18/feature/element-cache

f0cc846
Select commit
Loading
Failed to load commit list.
CodeScene Delta Analysis / CodeScene Code Health Review (v18/dev) failed Apr 9, 2026 in 1m 10s

CodeScene PR Check

Quality Gate Failed

Code Health Improved (1 files improve in Code Health)

Gates Failed
Enforce critical code health rules (1 file with Bumpy Road Ahead, Deep, Nested Complexity)
Enforce advisory code health rules (12 files with Code Duplication, Complex Conditional, Primitive Obsession, Constructor Over-Injection, Missing Arguments Abstractions, Large Method, Complex Method)

Gates Passed
2 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Enforce critical code health rules Violations Code Health Impact
ElementBreadthFirstKeyProvider.cs 2 critical rules 8.91 Suppress
Enforce advisory code health rules Violations Code Health Impact
ElementBreadthFirstKeyProvider.cs 1 advisory rule 8.91 Suppress
ApiContentRouteBuilder.cs 2 advisory rules 9.39 → 8.55 Suppress
DatabaseCacheRepository.cs 2 advisory rules 4.95 → 4.32 Suppress
ElementCacheService.cs 2 advisory rules 10.00 → 9.39 Suppress
PublishStatusRepository.cs 1 advisory rule 10.00 → 9.39 Suppress
ElementCacheServiceTests.cs 1 advisory rule 9.39 Suppress
ElementBreadthFirstKeyProviderTests.cs 1 advisory rule 9.39 Suppress
DocumentUrlService.cs 1 advisory rule 5.82 → 5.33 Suppress
CacheManager.cs 1 advisory rule 10.00 → 9.69 Suppress
ElementCacheRefresher.cs 1 advisory rule 9.69 → 9.39 Suppress
UmbracoBuilder.cs 1 advisory rule 8.53 → 8.48 Suppress
ContentCacheRefresher.cs 1 advisory rule no change Suppress
View Improvements
File Code Health Impact Categories Improved
CacheRefreshingNotificationHandler.cs 9.39 → 10.00 Code Duplication

Quality Gate Profile: Clean Code Collective
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

Details

🚩 Declining Code Health (highest to lowest):

  • Large Method UmbracoBuilder.cs: AddCoreServices
  • Code Duplication DatabaseCacheRepository.cs
  • Complex Conditional DatabaseCacheRepository.cs: Rebuild
  • Code Duplication DocumentUrlService.cs
  • Code Duplication ContentCacheRefresher.cs
  • Code Duplication ApiContentRouteBuilder.cs
  • Code Duplication PublishStatusRepository.cs
  • Deep, Nested Complexity ElementBreadthFirstKeyProvider.cs: GetSeedKeys
  • Code Duplication ElementCacheServiceTests.cs
  • Code Duplication ElementBreadthFirstKeyProviderTests.cs
  • Complex Method ElementBreadthFirstKeyProvider.cs: GetSeedKeys
  • Complex Conditional ElementCacheRefresher.cs: HandlePublishStatus
  • Missing Arguments Abstractions ApiContentRouteBuilder.cs
  • Constructor Over-Injection CacheManager.cs: CacheManager
  • Primitive Obsession ElementCacheService.cs
  • Constructor Over-Injection ElementCacheService.cs: ElementCacheService
  • Complex Conditional DatabaseCacheRepository.cs: GetElementSourceAsync
  • Complex Conditional DatabaseCacheRepository.cs: GetDocumentSourceAsync
  • Bumpy Road Ahead ElementBreadthFirstKeyProvider.cs: GetSeedKeys

✅ Improving Code Health:

  • Code Duplication DatabaseCacheRepository.cs: GetContentSourcesAsync
  • Code Duplication ElementPublishingServiceTests.Publish.cs: Cannot_Get_Published_Again_After_Trashing
  • Complex Conditional DatabaseCacheRepository.cs: GetContentSourceAsync
  • Primitive Obsession DocumentUrlService.cs
  • Large Method DatabaseCacheRepository.cs: BuildCacheDtosForDocument
  • Excess Number of Function Arguments DatabaseCacheRepository.cs: BuildCacheDtosForDocument
  • Constructor Over-Injection ContentCacheRefresher.cs: ContentCacheRefresher
  • Overall Code Complexity ContentCacheRefresher.cs
  • Code Duplication CacheRefreshingNotificationHandler.cs

Annotations

Check notice on line 1 in src/Umbraco.PublishedCache.HybridCache/NotificationHandlers/CacheRefreshingNotificationHandler.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

✅ No longer an issue: Code Duplication

The module no longer contains too many functions with similar structure

Check warning on line 59 in src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ Getting worse: Code Duplication

introduced similar code in: GetDocumentCultureDataForNodes,GetDocumentMetadataForNodes,GetDocumentSourceAsync,GetDocumentSourceForPublishStatesAsync and 12 more functions. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check notice on line 1 in src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

✅ Getting better: Code Duplication

reduced similar code in: GetContentSourcesAsync. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check warning on line 210 in src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ Getting worse: Complex Conditional

Rebuild increases from 1 complex conditionals with 5 branches to 1 complex conditionals with 7 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.

Check notice on line 1 in src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

✅ No longer an issue: Complex Conditional

GetContentSourceAsync no longer has a complex conditional. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.

Check warning on line 103 in src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Complex Conditional

GetElementSourceAsync has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.

Check warning on line 1 in src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Complex Conditional

GetDocumentSourceAsync has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.

Check notice on line 867 in src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

✅ No longer an issue: Large Method

BuildCacheDtosForDocument is no longer above the threshold for lines of code. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

Check notice on line 867 in src/Umbraco.PublishedCache.HybridCache/Persistence/DatabaseCacheRepository.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

✅ No longer an issue: Excess Number of Function Arguments

BuildCacheDtosForDocument is no longer above the threshold for number of arguments. This function has too many arguments, indicating a lack of encapsulation. Avoid adding more arguments.

Check warning on line 1 in src/Umbraco.PublishedCache.HybridCache/Services/ElementCacheService.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Primitive Obsession

In this module, 38.7% of all function arguments are primitive types, threshold = 30.0%. The functions in this file have too many primitive types (e.g. int, double, float) in their function argument lists. Using many primitive types lead to the code smell Primitive Obsession. Avoid adding more primitive arguments.

Check warning on line 77 in src/Umbraco.PublishedCache.HybridCache/Services/ElementCacheService.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Constructor Over-Injection

ElementCacheService has 10 arguments, max arguments = 5. This constructor has too many arguments, indicating an object with low cohesion or missing function argument abstraction. Avoid adding more arguments.

Check warning on line 112 in src/Umbraco.Core/Cache/Refreshers/Implement/ContentCacheRefresher.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Code Duplication

The module contains 3 functions with similar structure: ContentCacheRefresher,ContentCacheRefresher,ContentCacheRefresher. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check notice on line 1 in src/Umbraco.Core/Cache/Refreshers/Implement/ContentCacheRefresher.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

✅ No longer an issue: Overall Code Complexity

The mean cyclomatic complexity in this module is no longer above the threshold

Check notice on line 112 in src/Umbraco.Core/Cache/Refreshers/Implement/ContentCacheRefresher.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

✅ Getting better: Constructor Over-Injection

ContentCacheRefresher decreases from 15 to 14 arguments, max arguments = 5. This constructor has too many arguments, indicating an object with low cohesion or missing function argument abstraction. Avoid adding more arguments.

Check warning on line 185 in src/Umbraco.Core/Cache/Refreshers/Implement/ElementCacheRefresher.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Complex Conditional

HandlePublishStatus has 1 complex conditionals with 2 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.

Check warning on line 63 in src/Umbraco.Core/DeliveryApi/ApiContentRouteBuilder.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Code Duplication

The module contains 2 functions with similar structure: ApiContentRouteBuilder,ApiContentRouteBuilder. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check warning on line 1 in src/Umbraco.Core/DeliveryApi/ApiContentRouteBuilder.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Missing Arguments Abstractions

The average number of function arguments in this module is 4.63 across 8 functions. The average arguments threshold is 4.00. The functions in this file have too many arguments, indicating a lack of encapsulation or too many responsibilities in the same functions. Avoid adding more.

Check warning on line 402 in src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ Getting worse: Large Method

AddCoreServices increases from 226 to 236 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

Check warning on line 154 in src/Umbraco.Core/Services/DocumentUrlService.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Code Duplication

The module contains 5 functions with similar structure: DocumentUrlService,DocumentUrlService,DocumentUrlService,GetUrlSegment and 1 more functions. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check notice on line 1 in src/Umbraco.Core/Services/DocumentUrlService.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

✅ Getting better: Primitive Obsession

The ratio of primitive types in function arguments decreases from 51.67% to 40.52%, threshold = 30.0%. The functions in this file have too many primitive types (e.g. int, double, float) in their function argument lists. Using many primitive types lead to the code smell Primitive Obsession. Avoid adding more primitive arguments.

Check warning on line 152 in src/Umbraco.Infrastructure/Persistence/Repositories/Implement/PublishStatusRepository.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Code Duplication

The module contains 2 functions with similar structure: GetBaseQuery,GetElementBaseQuery. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.

Check warning on line 99 in src/Umbraco.PublishedCache.HybridCache/SeedKeyProviders/Element/ElementBreadthFirstKeyProvider.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Complex Method

GetSeedKeys has a cyclomatic complexity of 13, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check warning on line 99 in src/Umbraco.PublishedCache.HybridCache/SeedKeyProviders/Element/ElementBreadthFirstKeyProvider.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Bumpy Road Ahead

GetSeedKeys has 3 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.

Check warning on line 99 in src/Umbraco.PublishedCache.HybridCache/SeedKeyProviders/Element/ElementBreadthFirstKeyProvider.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Deep, Nested Complexity

GetSeedKeys has a nested complexity depth of 4, threshold = 4. This function contains deeply nested logic such as if statements and/or loops. The deeper the nesting, the lower the code health.

Check warning on line 129 in tests/Umbraco.Tests.Integration/Umbraco.PublishedCache.HybridCache/ElementCacheServiceTests.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Code Health Review (v18/dev)

❌ New issue: Code Duplication

The module contains 4 functions with similar structure: CreateAndSaveElement,CreateSaveAndPublishElement,Rebuild_Creates_Draft_And_Published_Cache_Records,Rebuild_Creates_Draft_Cache_Record_With_Property_Data. Avoid duplicated, aka copy-pasted, code inside the module. More duplication lowers the code health.