Skip to content

Utility library for generating consistent cache dependency keys for Kentico CMS applications

License

Notifications You must be signed in to change notification settings

wiredviews/kentico-fluent-cache-keys

Repository files navigation

Kentico Fluent Cache Keys

Utility library for generating consistent cache dependency keys for Kentico Xperience applications

GitHub Actions CI: Build

Publish Packages to NuGet

Packages

NuGet Package

How to Use?

  1. Install the WiredViews.Kentico.FluentCacheKeys NuGet package in your project:

    dotnet add package WiredViews.Kentico.FluentCacheKeys

Examples

Creating cache keys for pages / documents / nodes

FluentCacheKey.ForPage().WithDocumentId(5);

FluentCacheKey.ForPage().WithNodeId(4);

FluentCacheKey.ForPage().RelationshipsOfNodeId(4);

FluentCacheKey.ForPage().OfSite("Sandbox").WithAliasPath("/home");

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

FluentCacheKey.ForObject().OfClassName(UserInfo.OBJECT_TYPE).WithName("administrator");

FluentCacheKey.ForObject().OfClassName(UserInfo.OBJECT_TYPE).WithGuid(new Guid("9fb0c012-5d9b-4eb6-b5cd-0bb0daffaca0"));

FluentCacheKey.ForObject().OfClassName(UserInfo.OBJECT_TYPE).WithId(2);

FluentCacheKey.ForObjects().OfClassName(UserInfo.OBJECT_TYPE).All();

Creating cache keys for attachments

FluentCacheKey.ForAttachment().WithGuid(new Guid("9fb0c012-5d9b-4eb6-b5cd-0bb0daffaca0"));

FluentCacheKey.ForAttachments().OfDocumentId(4);

FluentCacheKey.ForAttachments().All();

Creating cache keys for media files

FluentCacheKey.ForMediaFile().WithGuid(new Guid("9fb0c012-5d9b-4eb6-b5cd-0bb0daffaca0"));

FluentCacheKey.ForMediaFile().PreviewWithGuid(new Guid("9fb0c012-5d9b-4eb6-b5cd-0bb0daffaca0"));

Creating cache keys for custom tables

FluentCacheKey.ForCustomTable().OfClassName("MyCustomTable").All();

FluentCacheKey.ForCustomTable().OfClassName("MyCustomTable").WithRecordId(5);

Creating cache keys for settings

FluentCacheKey.ForSetting().WithCodeName("settingKeyName");

FluentCacheKey.ForSetting().OfSiteId(1).WithCodeName("settingKeyName");

Contributions

If you discover a problem, please open an issue.

If you would like contribute to the code or documentation, please open a pull request.

References

Kentico Documentation

Blog Posts