Skip to content

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
wants to merge 20 commits into
base: main
Choose a base branch
from
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 Jun 2, 2025
da2192f
Apply suggestions from code review
Migaroez Jul 14, 2025
ab385da
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
a40939d
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
216b0b4
Update 13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
4a948d2
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
5f6d278
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
3d0cc01
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
bbf9c18
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
97ceb8d
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
6119a07
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
c7175d0
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
837ec7d
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
e90fc5c
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
333086a
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
6ee05bf
Update 13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
c7b5fd1
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
39386f5
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
2b04589
Update 13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
14f0e0e
Update 16/umbraco-cms/reference/cache/imemberpartialviewcacheinvalida…
eshanrnh Jul 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Contributor

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?



## 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>();
}
}
```
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>();
}
}
```