Skip to content

Commit da2192f

Browse files
Apply suggestions from code review
Co-authored-by: Andy Butland <[email protected]>
1 parent 87efc58 commit da2192f

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

13/umbraco-cms/reference/cache/imemberpartialviewcacheinvalidator.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
# ICacheRefresher
1+
# Partial view cache refresher for members
22

3-
This section describes what IMemberPartialViewCacheInvalidator is, what it's default implementation does and how to customize it.
3+
This section describes the `IMemberPartialViewCacheInvalidator` interface, what it's default implementation does and how to customize it.
44

5-
## What is an IMemberPartialViewCacheInvalidator
5+
## What is an IMemberPartialViewCacheInvalidator?
66

7-
This interface is used to isolate the logic that needs to run to invalidate parts of the PartialView cache when a member is updated
7+
This interface is used to isolate the logic that invalidates parts of the partial view cache when a member is updated.
88

9-
## Why do we need to partialy invalidate the partialView cache
9+
## Why do we need to partially invalidate the partial view cache?
1010

11-
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.
11+
Razor templates showing data retrieved from a member object can be cached as partial views via:
1212

13-
## Where is it used
1413

15-
This interface is called from the MemberCacheRefresher which is called every time a member is updated.
14+
## Where is it used?
1615

17-
## Details of the implementation
16+
This interface is called from the member cache refresher (`MemberCacheRefresher`) which is invoked every time a member is updated.
17+
18+
## Details of the default implementation
19+
20+
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-`.
21+
22+
When the `ClearPartialViewCacheItems` method is called it will clear all cache items that match the marker for the updated members.
1823

19-
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.
20-
When the `ClearPartialViewCacheItems` method is called it will clear all PartialView cacheItems that have the memberId marker for all passed in members.
2124
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-`)
2225

2326
## Customizing the implementation
2427

25-
You can replace the default implementation like usual by removing the default and registering your own in a composer.
28+
You can replace the default implementation by removing it and registering your own in a composer.
2629

2730
```csharp
2831
public class ReplaceMemberCacheInvalidatorComposer : IComposer

0 commit comments

Comments
 (0)