Utility library for generating consistent cache dependency keys for Kentico Xperience applications
-
Install the
WiredViews.Kentico.FluentCacheKeys
NuGet package in your project:dotnet add package WiredViews.Kentico.FluentCacheKeys
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();
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();
FluentCacheKey.ForAttachment().WithGuid(new Guid("9fb0c012-5d9b-4eb6-b5cd-0bb0daffaca0"));
FluentCacheKey.ForAttachments().OfDocumentId(4);
FluentCacheKey.ForAttachments().All();
FluentCacheKey.ForMediaFile().WithGuid(new Guid("9fb0c012-5d9b-4eb6-b5cd-0bb0daffaca0"));
FluentCacheKey.ForMediaFile().PreviewWithGuid(new Guid("9fb0c012-5d9b-4eb6-b5cd-0bb0daffaca0"));
FluentCacheKey.ForCustomTable().OfClassName("MyCustomTable").All();
FluentCacheKey.ForCustomTable().OfClassName("MyCustomTable").WithRecordId(5);
FluentCacheKey.ForSetting().WithCodeName("settingKeyName");
FluentCacheKey.ForSetting().OfSiteId(1).WithCodeName("settingKeyName");
If you discover a problem, please open an issue.
If you would like contribute to the code or documentation, please open a pull request.
-
Setting cache dependencies for cache dependency key examples.
-
Caching in custom code for examples of how to use these keys.
- Kentico 12: Design Patterns Part 12 - Database Query Caching Patterns for best practices for caching in your application.