Skip to content

Commit

Permalink
Added node order cache dependency key
Browse files Browse the repository at this point in the history
  • Loading branch information
ArjanvHugten committed Jan 18, 2023
1 parent 1a46005 commit dcc41a1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ FluentCacheKey.ForPage().OfSite("Sandbox").WithAliasPath("/home", "en-us");
FluentCacheKey.ForPages().OfSite("Sandbox").OfClassName(HomePage.CLASS_NAME);
FluentCacheKey.ForPages().OfSite("Sandbox").UnderAliasPath("/home");
FluentCacheKey.ForPagesNodeOrder().All();
```

### Creating cache keys for CMS objects / custom module classes
Expand Down
12 changes: 12 additions & 0 deletions src/KenticoFluentCacheKeys/FluentCacheKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public interface ISitePageCacheDependencyKey
string SiteName { get; }
}
public interface IPagesCacheDependencyKey { }
public interface IPagesNodeOrderCacheDependencyKey { }
public interface ISitePagesCacheDependencyKey
{
string SiteName { get; }
Expand Down Expand Up @@ -48,6 +49,7 @@ public class FluentCacheKey :
IPageCacheDependencyKey,
ISitePageCacheDependencyKey,
IPagesCacheDependencyKey,
IPagesNodeOrderCacheDependencyKey,
ISitePagesCacheDependencyKey,
IObjectCacheDependencyKey,
IObjectOfClassNameCacheDependencyKey,
Expand Down Expand Up @@ -79,6 +81,13 @@ public static IPageCacheDependencyKey ForPage() =>
public static IPagesCacheDependencyKey ForPages() =>
new FluentCacheKey(null, null);

/// <summary>
/// Builds Document and Node related cache dependency keys for changes in the node order
/// </summary>
/// <returns></returns>
public static IPagesNodeOrderCacheDependencyKey ForPagesNodeOrder() =>
new FluentCacheKey(null, null);

/// <summary>
/// Builds CMS Object and custom Module Class related cache dependency keys for a single object
/// </summary>
Expand Down Expand Up @@ -162,6 +171,9 @@ public static string WithNodeGuid(this ISitePageCacheDependencyKey key, Guid nod

public static class PagesCacheDependencyExtensions
{
public static string All(this IPagesNodeOrderCacheDependencyKey _) =>
"nodeorder";

public static ISitePagesCacheDependencyKey OfSite(this IPagesCacheDependencyKey _, string siteName) =>
new FluentCacheKey(null, siteName);

Expand Down
8 changes: 8 additions & 0 deletions tests/KenticoFluentCacheKeys.Tests/FluentCacheKeysTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ public void ForPages_OfSite_UnderAliasPath_Will_Create_A_Valid_Key(string siteNa
key.Should().Be($"node|{siteName}|{aliasPath}|childnodes");
}

[Fact]
public void ForPagesNodeOrder_All_Will_Create_A_Valid_Key()
{
string key = FluentCacheKey.ForPagesNodeOrder().All();

key.Should().Be("nodeorder");
}

[Theory, AutoData]
public void ForPages_OfSite_OfClass_Will_Create_A_Valid_Key(string siteName, string className)
{
Expand Down

0 comments on commit dcc41a1

Please sign in to comment.