Skip to content

Commit c25cf36

Browse files
committed
Update the comments
Some of them referred to the old way, and it's helped me understand what's going on to tweak them!
1 parent e1df6b1 commit c25cf36

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

Our.Umbraco.TagHelpers/Notifications/CacheRefresherNotifications.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
namespace Our.Umbraco.TagHelpers.Notifications
88
{
9-
// For Use with the Our Cache TagHelper - to store a last cache updated datetime to use
10-
// in the varyby key for the Cache TagHelper, to naively break the cache on publish.
11-
// Used for ContentCacheRefresher (Load balanced scernarios not just Published event)
12-
// Same for Dictionary Items and Media item
9+
/// <summary>
10+
/// For Use with the Our Cache TagHelper
11+
/// We handle the published cache updating notification for content, media and dictionary
12+
/// And then use our dictionary collection of tracked tag helper caches, created in the tag cache helper
13+
/// loop through each one and clear the tag helpers cache
14+
/// </summary>
1315
public class CacheTagRefresherNotifications :
1416
INotificationHandler<ContentCacheRefresherNotification>,
1517
INotificationHandler<DictionaryCacheRefresherNotification>,

Our.Umbraco.TagHelpers/Services/UmbracoTagHelperCacheKeys.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
namespace Our.Umbraco.TagHelpers.Services
55
{
6+
/// <summary>
7+
/// used to retain a list of hashed cache tag helper keys that have been created using the our cache tag helper
8+
/// and which need to be cleared when a publish notification takes place.
9+
/// </summary>
610
public class UmbracoTagHelperCacheKeys : IUmbracoTagHelperCacheKeys
711
{
812
public Dictionary<string,CacheTagKey> CacheKeys { get; } = new Dictionary<string,CacheTagKey>();

Our.Umbraco.TagHelpers/UmbracoCacheTagHelper.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
namespace Our.Umbraco.TagHelpers
1111
{
1212
/// <summary>
13-
/// A wrapper around .net core CacheTagHelper so you remember not to cache in preview or Umbraco debug mode
14-
/// Also can create a new variance of the cache when anything is published in Umbraco if that is desirable
13+
/// A wrapper around .net core CacheTagHelper, that is Umbraco Aware - so won't cache in Preview or Debug Mode
14+
/// And will automatically clear it's when anything is published (optional)
1515
/// </summary>
1616
[HtmlTargetElement("our-cache")]
1717
public class UmbracoCacheTagHelper : CacheTagHelper
@@ -43,19 +43,23 @@ public override async Task ProcessAsync(TagHelperContext context, TagHelperOutpu
4343
// we don't want to enable the cache tag helper if Umbraco is in Preview, or in Debug mode
4444
if (umbracoContext.InPreviewMode || umbracoContext.IsDebug)
4545
{
46-
// Set the endabled flag to false & lest base class
47-
// of the cache tag helper do the same stuff as before
46+
// Set the enabled flag to false & let base class
47+
// of the cache tag helper do the disabling of the cache
4848
this.Enabled = false;
4949
}
5050
else
5151
{
52-
// Defaults to true - have to explicitly opt out with attribute set to false in Razor
52+
// Now whenever anything is published in Umbraco 'the old Umbraco Cache Helper convention' was to clear out all the view memory caches
53+
// we want to do the same by default for this tag helper
54+
// we can't track by convention as dot net tag helper cache key is hashed - but we can generte the hash key here, and add it to a dictionary
55+
// which we can loop through when the Umbraco cache is updated to clear the tag helper cache.
56+
// you can opt out of this by setting update-cache-key-on-publish="false" in the individual tag helper
5357
if (UpdateCacheKeyOnPublish)
5458
{
55-
// So before we go into our base class
56-
// Grab the cache key so we can keep track of it & put into some dictionary or collection
59+
// The base TagHelper would generate it's own CacheTagKey to create a unique hash
60+
// but if we call it here 'too' it will fortunately be the same hash.
61+
// so we can keep track of it & put into some dictionary or collection
5762
// and clear all items out in that collection with our notifications on publish
58-
5963
var cacheKey = new CacheTagKey(this, context);
6064
var key = cacheKey.GenerateKey();
6165
var hashedKey = cacheKey.GenerateHashedKey();

0 commit comments

Comments
 (0)