Skip to content

Performance: Implement key-based caching for data type and template repositories#20

Open
Franck-Boost wants to merge 9 commits intomainfrom
v17/improvement/key-cache-for-content-related-entities
Open

Performance: Implement key-based caching for data type and template repositories#20
Franck-Boost wants to merge 9 commits intomainfrom
v17/improvement/key-cache-for-content-related-entities

Conversation

@Franck-Boost
Copy link

Description

We currently have nested repositories for reading documents and media by GUID, that are aligned with the main repository to ensure that if a request is made by Id, it's cached by key, and vice versa (see umbraco#21124).

Whilst this may not be architecturally ideal, it does follow an existing and established pattern, so seems reasonable in advance of more significant repository refactoring.

In practice, this didn't show any obvious improvement in save/publish time, but nonetheless feels a sensible update to make to ensure these requests for data types and templates are cached however they are retrieved.

In working on this PR I verified that this is already in place for content types, as we have policy there of retrieving all and caching them, so by ID/key look-ups always come from this already cached collection.

Change Details

  • Implements GUID key caching for DataTypeRepository and TemplateRepository to improve lookup performance
  • When entities are retrieved by int ID, they are also cached for GUID lookups (and vice versa)
  • Adds comprehensive tests verifying caching behavior for content types, data types, and templates

Testing

Integration tests have been added to verify the behaviour:

  • Verify that retrieving a data type by ID then by GUID does not hit the database on the second call
  • Verify that retrieving a template by ID then by GUID does not hit the database on the second call
  • Verify existing content type caching behaviour is already correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants