Merged
Conversation
Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
Co-authored-by: Ronald Barendse <ronald@barend.se>
…into v15/feature/update-to-dotnet-9
Merged
|
Will this change also affect Isolated caches? Will they become distributed if L2 cache will be configured? |
Contributor
|
No, there has been no change in this regard |
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Oct 29, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Dec 12, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Dec 24, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Dec 24, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Dec 24, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Dec 24, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Dec 24, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Dec 24, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Dec 24, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Dec 24, 2025
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Jan 5, 2026
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Jan 5, 2026
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Jan 5, 2026
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Jan 6, 2026
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Jan 6, 2026
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Jan 7, 2026
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Jan 7, 2026
sussexrick
added a commit
to thepensionsregulator/govuk-frontend-aspnetcore-extensions
that referenced
this pull request
Jan 7, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hybrid Caching
This PR introduces new hybrid cache implementations of the cache interfaces,
If you want to learn more about what hybrid caching is, read: https://learn.microsoft.com/en-us/aspnet/core/performance/caching/hybrid?view=aspnetcore-9.0
Second level cache
For how to implement a secondary cache with this, see: https://learn.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-9.0#distributed-redis-cache
Additions to the cache interfaces
IPublishedMemberCacheIPublishedMediaCacheIPublishedContentCacheAnd with this PR, we add some async methods to these. This way we break less code, but we can also modernize with some async methods.
What happened to PublishedSnapshot?
With nucache, we had a concept of a
PublishedSnapshot, this was a cache snapshot, so that you would have the same entities during a request, so that if anything got changed /deleted during your request, that would not interfere / cause errors.This is no longer a thing with the Hybrid Cache, as it has no concept of cache snapshots.
This also means that
IPublishedSnapshot,IPublishedSnapshotAccessor&SnapshotCacheis all obsolete.And even the
PropertyCacheLevel.Snapshotis also obsolete.The Hybrid Cache project
Cache implementations
The cache implementations instead of having tons of logic inside them, now calls the cache service instead to get out items.
Note that theres a lot of not implemented methods here, as they are all obsolete, and no longer part of this caching.
Thus they will have to be removed when we remove NuCache.
What Caches do we have now then?
PropertyCacheLevel.ElementsThe cache services
These cache services that the caches use, now use the new snazzy dotnet 9 feature
HybridCache.Cache service responsibility includes:
IPublishedContentPublishedContent changes
PublishedContent no longer has any Tree logic, this means, we no longer have children / parent.
PublishedProperty
The big change to PublishedProperty is that we no longer use snapshots, so in the
GetCacheValuesmethod, we can avoid using snapshot, and instead just fall back to theElementbehavior.Seeding
So for NuCache, it would load everything into memory, this is really performant when everything is finally loaded in. But causes issues like :
So we have strayed from this approach with this. We do however recognize that sometimes you might want to have some pages always in memory (stuff like the front page), this is where the seeding feature comes in.
You can now instead deine a list of content type ids in
appsettings.json, which in turn will load every document that uses the given document types, into the cache, and will never evict them.This new setting can be set like:
Features still missing
How to test
Note: We can't do a full proper tests before we can replace NuCache. And we can only replace NuCache once this and #16818 is merged 😁
For now we can instead test this with trying out some distributed cache implementation, and asserting entities actually are in the cache, both after getting the entity, but also seeding.
We will now use the SqlServer distributed cache, you can directly follow the documentation here: https://learn.microsoft.com/en-us/aspnet/core/performance/caching/distributed?view=aspnetcore-8.0#distributed-sql-server-cache
It would also be nice to tests this with other implementations of this, like Redis.
(localdb)\MSSQLLocalDBand created a database calledDistCachedotnet sql-cache create "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=DistCache;Integrated Security=True;" dbo TestCacheMicrosoft.Extensions.Caching.SqlServerto the Web.UI projectprogram.cs, paste this on line 2:dbo.TestCachetable, this should now contain 1 entry, and that should be your content you created with the "RootSeed" contentype,https://localhost:44339/My)