Simplifies compression implementation, adds compression options to target all complex editors, ensures the options are per document type/property type

This commit is contained in:
Shannon
2020-08-26 15:57:13 +10:00
parent ba8da3850e
commit 9a06b6291a
20 changed files with 155 additions and 525 deletions

View File

@@ -3,6 +3,7 @@ using System.Configuration;
using System.Linq;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Web.PropertyEditors;
using Umbraco.Web.PublishedCache.NuCache.DataSource;
namespace Umbraco.Web.PublishedCache.NuCache
@@ -14,36 +15,22 @@ namespace Umbraco.Web.PublishedCache.NuCache
base.Compose(composition);
var serializer = ConfigurationManager.AppSettings["Umbraco.Web.PublishedCache.NuCache.Serializer"];
composition.Register<INuCachePropertyOptionsFactory, AppSettingsNuCachePropertyMapFactory>();
composition.Register<Lz4DictionaryOfPropertyDataSerializer, Lz4DictionaryOfPropertyDataSerializer>();
// TODO: Based on our findings it seems like this should not be configurable, we should just be using this because it's better
if (serializer == "MsgPack")
if (serializer != "MsgPack")
{
var propertyDictionarySerializer = ConfigurationManager.AppSettings["Umbraco.Web.PublishedCache.NuCache.DictionaryOfPropertiesSerializer"];
if (propertyDictionarySerializer == "LZ4Map")
{
composition.Register(factory =>
{
var lz4Serializer = factory.GetInstance<Lz4DictionaryOfPropertyDataSerializer>();
return new ContentDataSerializer(lz4Serializer);
});
}
else
{
composition.Register(factory => new ContentDataSerializer(new DictionaryOfPropertyDataSerializer()));
}
composition.Register<IContentNestedDataSerializer, MsgPackContentNestedDataSerializer>();
// TODO: This allows people to revert to the legacy serializer, by default it will be MessagePack
composition.RegisterUnique<IContentNestedDataSerializer, JsonContentNestedDataSerializer>();
composition.RegisterUnique<IPropertyCompressionOptions, NoopPropertyCompressionOptions>();
}
else
{
composition.Register<IContentNestedDataSerializer, JsonContentNestedDataSerializer>();
composition.Register(factory => new ContentDataSerializer(new DictionaryOfPropertyDataSerializer()));
composition.RegisterUnique<IContentNestedDataSerializer, MsgPackContentNestedDataSerializer>();
composition.RegisterUnique<IPropertyCompressionOptions, ComplexEditorPropertyCompressionOptions>();
}
composition.RegisterUnique(factory => new ContentDataSerializer(new DictionaryOfPropertyDataSerializer()));
// register the NuCache database data source
composition.Register<IDataSource, DatabaseDataSource>();
composition.RegisterUnique<IDataSource, DatabaseDataSource>();
// register the NuCache published snapshot service
// must register default options, required in the service ctor