From 044585a4f3a0e77a3a73b2bd45e06abf2b0d2db3 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 13 Aug 2020 22:22:06 +1000 Subject: [PATCH] removes the SQLDatabase enum value --- .../IContentNestedDataSerializer.cs | 2 +- .../Lz4DictionaryOfPropertyDataSerializer.cs | 1 - .../MsgPackContentNestedDataSerializer.cs | 50 ++----------------- .../NucachePropertyCompressionLevel.cs | 8 --- 4 files changed, 5 insertions(+), 56 deletions(-) diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/IContentNestedDataSerializer.cs b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/IContentNestedDataSerializer.cs index 32eb388bee..8b1b3e1496 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/IContentNestedDataSerializer.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/IContentNestedDataSerializer.cs @@ -5,7 +5,7 @@ /// /// Serializes/Deserializes document to the SQL Database as bytes /// - public interface IContentNestedDataByteSerializer : IContentNestedDataSerializer + public interface IContentNestedDataByteSerializer { ContentNestedData DeserializeBytes(byte[] data); byte[] SerializeBytes(ContentNestedData nestedData); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/Lz4DictionaryOfPropertyDataSerializer.cs b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/Lz4DictionaryOfPropertyDataSerializer.cs index 31f7763e04..d71f0e2184 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/Lz4DictionaryOfPropertyDataSerializer.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/Lz4DictionaryOfPropertyDataSerializer.cs @@ -68,7 +68,6 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource switch (map.CompressLevel) { - case NucachePropertyCompressionLevel.SQLDatabase: case NucachePropertyCompressionLevel.NuCacheDatabase: if (!(pdata.Value is null) && pdata.Value is byte[] byteArrayValue) { diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/MsgPackContentNestedDataSerializer.cs b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/MsgPackContentNestedDataSerializer.cs index 206051f839..33181ebd5e 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/MsgPackContentNestedDataSerializer.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/MsgPackContentNestedDataSerializer.cs @@ -1,23 +1,17 @@ -using K4os.Compression.LZ4; -using MessagePack; -using MessagePack.Formatters; +using MessagePack; using MessagePack.Resolvers; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Umbraco.Web.PublishedCache.NuCache.DataSource { /// /// Serializes/Deserializes document to the SQL Database as bytes using MessagePack /// - internal class MsgPackContentNestedDataSerializer : IContentNestedDataByteSerializer + internal class MsgPackContentNestedDataSerializer : IContentNestedDataByteSerializer, IContentNestedDataSerializer { - private MessagePackSerializerOptions _options; - private readonly NuCachePropertyOptions _propertyOptions; + private readonly MessagePackSerializerOptions _options; - public MsgPackContentNestedDataSerializer(INuCachePropertyOptionsFactory propertyOptionsFactory = null) + public MsgPackContentNestedDataSerializer() { var defaultOptions = ContractlessStandardResolver.Options; @@ -37,7 +31,6 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource _options = defaultOptions .WithResolver(resolver) .WithCompression(MessagePackCompression.Lz4BlockArray); - _propertyOptions = propertyOptionsFactory?.GetNuCachePropertyOptions() ?? new NuCachePropertyOptions(); } public string ToJson(string serialized) @@ -56,45 +49,10 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource public string Serialize(ContentNestedData nestedData) { - Optimize(nestedData); - var bin = MessagePackSerializer.Serialize(nestedData, _options); return Convert.ToBase64String(bin); } - /// - /// Compress properties and map property names to shorter names - /// - /// - private void Optimize(ContentNestedData nestedData) - { - if (_propertyOptions.PropertyMap != null && _propertyOptions.PropertyMap.Count > 0) - { - foreach (var map in _propertyOptions.PropertyMap) - { - if (map.Value.CompressLevel.Equals(NucachePropertyCompressionLevel.SQLDatabase)) - { - if (nestedData.PropertyData.TryGetValue(map.Key, out PropertyData[] properties)) - { - foreach (var property in properties.Where(x => x.Value != null && x.Value is string)) - { - property.Value = LZ4Pickler.Pickle(Encoding.UTF8.GetBytes(property.Value as string), _propertyOptions.LZ4CompressionLevel); - } - } - } - - // if there is an alias map for this property then use that instead of the real property alias - // (used to save memory, the mapped alias is normally a single char or at least a smaller string) - if (map.Value.MappedAlias != null && !map.Key.Equals(map.Value.MappedAlias) - && nestedData.PropertyData.Remove(map.Key) - && nestedData.PropertyData.TryGetValue(map.Key, out PropertyData[] properties2)) - { - nestedData.PropertyData.Add(map.Value.MappedAlias, properties2); - } - } - } - } - public ContentNestedData DeserializeBytes(byte[] data) => MessagePackSerializer.Deserialize(data, _options); public byte[] SerializeBytes(ContentNestedData nestedData) => MessagePackSerializer.Serialize(nestedData, _options); diff --git a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/NucachePropertyCompressionLevel.cs b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/NucachePropertyCompressionLevel.cs index 2f24a203ca..8a82dcb888 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/DataSource/NucachePropertyCompressionLevel.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/DataSource/NucachePropertyCompressionLevel.cs @@ -7,14 +7,6 @@ { None = 0, - /// - /// Compress property data at the nucache SQL DB table level - /// - /// - /// Only necessary if the document in the nucache SQL DB table isn't stored as compressed bytes - /// - SQLDatabase = 1, - /// /// Compress property data at the nucache BTree level ///