-
Notifications
You must be signed in to change notification settings - Fork 801
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
87efc58
da2192f
ab385da
a40939d
216b0b4
4a948d2
5f6d278
3d0cc01
bbf9c18
97ceb8d
6119a07
c7175d0
837ec7d
e90fc5c
333086a
6ee05bf
c7b5fd1
39386f5
2b04589
14f0e0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# ICacheRefresher | ||
|
||
This section describes what IMemberPartialViewCacheInvalidator is, what it's default implementation does and how to customize it. | ||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## What is an IMemberPartialViewCacheInvalidator | ||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This interface is used to isolate the logic that needs to run to invalidate parts of the PartialView cache when a member is updated | ||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Why do we need to partialy invalidate the partialView cache | ||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Since some of the razor templates might show data that is retrieved from a member object and those templates might be cached by using the partial caching mechanism (i.e. `@await Html.CachedPartialAsync("member",Model,TimeSpan.FromDays(1), cacheByMember:true)`), we need to remove those cached partials when a member is updated. | ||
Check warning on line 11 in 13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidator.md
|
||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Where is it used | ||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This interface is called from the MemberCacheRefresher which is called every time a member is updated. | ||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Details of the implementation | ||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
When a razor template partial is cached trough `Html.CachedPartialAsync` and `cacheByMember` is set to `true`, the extension method will append the memberId of the currently logged in member and a marker (i.e. `-m1015-`) to the partialView chachekey. | ||
Check warning on line 19 in 13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidator.md
|
||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
When the `ClearPartialViewCacheItems` method is called it will clear all PartialView cacheItems that have the memberId marker for all passed in members. | ||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Since it is possible to call the `Html.CachedPartialAsync` with `cacheByMember` set to `true` while there is no member logged in, it will also clear all cache items with an empty member marker (i.e. `-m-`) | ||
Check warning on line 21 in 13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidator.md
|
||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Customizing the implementation | ||
|
||
You can replace the default implementation like usual by removing the default and registering your own in a composer. | ||
Migaroez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```csharp | ||
public class ReplaceMemberCacheInvalidatorComposer : IComposer | ||
{ | ||
public void Compose(IUmbracoBuilder builder) | ||
{ | ||
builder.Services.AddUnique<IMemberPartialViewCacheInvalidator, MyCustomMemberPartialViewCacheInvalidator>(); | ||
} | ||
} | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# ICacheRefresher | ||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This section describes what IMemberPartialViewCacheInvalidator is, what it's default implementation does and how to customize it. | ||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## What is an IMemberPartialViewCacheInvalidator | ||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This interface is used to isolate the logic that needs to run to invalidate parts of the PartialView cache when a member is updated | ||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Why do we need to partialy invalidate the partialView cache | ||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Since some of the razor templates might show data that is retrieved from a member object and those templates might be cached by using the partial caching mechanism (i.e. `@await Html.CachedPartialAsync("member",Model,TimeSpan.FromDays(1), cacheByMember:true)`), we need to remove those cached partials when a member is updated. | ||
Check warning on line 11 in 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidator.md
|
||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Where is it used | ||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
This interface is called from the MemberCacheRefresher which is called every time a member is updated. | ||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Details of the implementation | ||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
When a razor template partial is cached trough `Html.CachedPartialAsync` and `cacheByMember` is set to `true`, the extension method will append the memberId of the currently logged in member and a marker (i.e. `-m1015-`) to the partialView chachekey. | ||
Check warning on line 19 in 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidator.md
|
||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
When the `ClearPartialViewCacheItems` method is called it will clear all PartialView cacheItems that have the memberId marker for all passed in members. | ||
Since it is possible to call the `Html.CachedPartialAsync` with `cacheByMember` set to `true` while there is no member logged in, it will also clear all cache items with an empty member marker (i.e. `-m-`) | ||
Check warning on line 21 in 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidator.md
|
||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Customizing the implementation | ||
|
||
You can replace the default implementation like usual by removing the default and registering your own in a composer. | ||
eshanrnh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```csharp | ||
public class ReplaceMemberCacheInvalidatorComposer : IComposer | ||
{ | ||
public void Compose(IUmbracoBuilder builder) | ||
{ | ||
builder.Services.AddUnique<IMemberPartialViewCacheInvalidator, MyCustomMemberPartialViewCacheInvalidator>(); | ||
} | ||
} | ||
``` |
Uh oh!
There was an error while loading. Please reload this page.