|
1 | | -# ICacheRefresher |
| 1 | +# Partial view cache refresher for members |
2 | 2 |
|
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. |
4 | 4 |
|
5 | | -## What is an IMemberPartialViewCacheInvalidator |
| 5 | +## What is an IMemberPartialViewCacheInvalidator? |
6 | 6 |
|
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. |
8 | 8 |
|
9 | | -## Why do we need to partialy invalidate the partialView cache |
| 9 | +## Why do we need to partially invalidate the partial view cache? |
10 | 10 |
|
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: |
12 | 12 |
|
13 | | -## Where is it used |
14 | 13 |
|
15 | | -This interface is called from the MemberCacheRefresher which is called every time a member is updated. |
| 14 | +## Where is it used? |
16 | 15 |
|
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. |
18 | 23 |
|
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. |
21 | 24 | 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-`) |
22 | 25 |
|
23 | 26 | ## Customizing the implementation |
24 | 27 |
|
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. |
26 | 29 |
|
27 | 30 | ```csharp |
28 | 31 | public class ReplaceMemberCacheInvalidatorComposer : IComposer |
|
0 commit comments