Make IPropertyCacheCompressionOptions useful out of the box. key = "Umbraco.Web.PublishedCache.NuCache.CompressUnPublishedContent" value = "true" will compress all ntext properties on unpublished content

This commit is contained in:
nzdev
2021-07-09 20:14:35 +12:00
parent 6b6525cc98
commit 044c900c2b
4 changed files with 41 additions and 2 deletions

View File

@@ -26,8 +26,16 @@ namespace Umbraco.Web.PublishedCache.NuCache
{
composition.RegisterUnique<IContentCacheDataSerializerFactory, MsgPackContentNestedDataSerializerFactory>();
}
composition.RegisterUnique<IPropertyCacheCompressionOptions, NoopPropertyCacheCompressionOptions>();
var unPublishedContentCompression = ConfigurationManager.AppSettings[NuCacheSerializerComponent.Nucache_UnPublishedContentCompression_Key];
if ("MsgPack" == serializer && "true" == unPublishedContentCompression)
{
composition.RegisterUnique<IPropertyCacheCompressionOptions, UnPublishedContentPropertyCacheCompressionOptions>();
}
else
{
composition.RegisterUnique<IPropertyCacheCompressionOptions, NoopPropertyCacheCompressionOptions>();
}
composition.RegisterUnique(factory => new ContentDataSerializer(new DictionaryOfPropertyDataSerializer()));

View File

@@ -16,6 +16,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
public class NuCacheSerializerComponent : IComponent
{
internal const string Nucache_Serializer_Key = "Umbraco.Web.PublishedCache.NuCache.Serializer";
internal const string Nucache_UnPublishedContentCompression_Key = "Umbraco.Web.PublishedCache.NuCache.CompressUnPublishedContent";
private const string JSON_SERIALIZER_VALUE = "JSON";
private readonly Lazy<IPublishedSnapshotService> _service;
private readonly IKeyValueService _keyValueService;