-
Notifications
You must be signed in to change notification settings - Fork 802
Added docs around IMemberPartialViewCacheInvalidator #7133
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
Open
Migaroez
wants to merge
20
commits into
main
Choose a base branch
from
new/member-partial-cache
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+75
β0
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
87efc58
Added docs around IMemberPartialViewCacheInvalidator
Migaroez da2192f
Apply suggestions from code review
Migaroez ab385da
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh a40939d
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 216b0b4
Update 13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 4a948d2
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 5f6d278
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 3d0cc01
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh bbf9c18
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 97ceb8d
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 6119a07
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh c7175d0
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 837ec7d
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh e90fc5c
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 333086a
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 6ee05bf
Update 13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh c7b5fd1
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 39386f5
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 2b04589
Update 13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 14f0e0e
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidaβ¦
eshanrnh 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
38 changes: 38 additions & 0 deletions
38
13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidator.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Partial view cache refresher for members | ||
|
||
This section describes the `IMemberPartialViewCacheInvalidator` interface, what it's default implementation does and how to customize it. | ||
|
||
## What is an IMemberPartialViewCacheInvalidator? | ||
|
||
This interface is used to isolate the logic that invalidates parts of the partial view cache when a member is updated. | ||
|
||
## Why do we need to partially invalidate the partial view cache? | ||
|
||
Razor templates showing data retrieved from a member object can be cached as partial views via: | ||
|
||
|
||
## Where is it used? | ||
|
||
This interface is called from the member cache refresher (`MemberCacheRefresher`), which is invoked every time a member is updated. | ||
|
||
## Details of the default implementation | ||
|
||
Razor template partials are cached through a call to `Html.CachedPartialAsync` with `cacheByMember` set to `true`. This will append the ID of the currently logged-in member with a marker to the partial view cache key. For example, `-m1015-`. | ||
|
||
When the `ClearPartialViewCacheItems` method is called it will clear all cache items that match the marker for the updated members. | ||
|
||
If no member is logged in during caching, items with an empty member marker (for example, `-m-`) are also cleared. | ||
|
||
## Customizing the implementation | ||
|
||
You can replace the default implementation by removing it and registering your own in a composer. | ||
|
||
```csharp | ||
public class ReplaceMemberCacheInvalidatorComposer : IComposer | ||
{ | ||
public void Compose(IUmbracoBuilder builder) | ||
{ | ||
builder.Services.AddUnique<IMemberPartialViewCacheInvalidator, MyCustomMemberPartialViewCacheInvalidator>(); | ||
} | ||
} | ||
``` |
37 changes: 37 additions & 0 deletions
37
16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidator.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Partial view cache refresher for members | ||
|
||
This section describes the `IMemberPartialViewCacheInvalidator` interface, what it's default implementation does and how to customize it. | ||
|
||
## What is an IMemberPartialViewCacheInvalidator? | ||
|
||
This interface is used to isolate the logic that invalidates parts of the partial view cache when a member is updated. | ||
|
||
## Why do we need to partially invalidate the partial view cache? | ||
|
||
Razor templates may show data that is retrieved from a member object. Those templates might be cached by using the partial caching mechanism (for example, `@await Html.CachedPartialAsync("member",Model,TimeSpan.FromDays(1), cacheByMember:true)`). When a member is updated, these cached partials must be invalidated to ensure updated data is shown. | ||
|
||
## Where is it used? | ||
|
||
This interface is called from the member cache refresher (`MemberCacheRefresher`), which is invoked every time a member is updated. | ||
|
||
## Details of the default implementation | ||
|
||
Razor template partials are cached through a call to `Html.CachedPartialAsync` with `cacheByMember` set to `true`. This will append the ID of the currently logged-in member with a marker to the partial view cache key. For example, `-m1015-`. | ||
|
||
When the `ClearPartialViewCacheItems` method is called, it will clear all cache items that match the marker for the updated members. | ||
|
||
If no member is logged in during caching, items with an empty member marker (for example, `-m-`) are also cleared. | ||
|
||
## Customizing the implementation | ||
|
||
You can replace the default implementation by removing it and registering your own in a composer. | ||
|
||
```csharp | ||
public class ReplaceMemberCacheInvalidatorComposer : IComposer | ||
{ | ||
public void Compose(IUmbracoBuilder builder) | ||
{ | ||
builder.Services.AddUnique<IMemberPartialViewCacheInvalidator, MyCustomMemberPartialViewCacheInvalidator>(); | ||
} | ||
} | ||
``` |
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.
This line is incomplete. Can you update it for both v13 and v16?