removes the SQLDatabase enum value
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
/// <summary>
|
||||
/// Serializes/Deserializes <see cref="ContentNestedData"/> document to the SQL Database as bytes
|
||||
/// </summary>
|
||||
public interface IContentNestedDataByteSerializer : IContentNestedDataSerializer
|
||||
public interface IContentNestedDataByteSerializer
|
||||
{
|
||||
ContentNestedData DeserializeBytes(byte[] data);
|
||||
byte[] SerializeBytes(ContentNestedData nestedData);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Serializes/Deserializes <see cref="ContentNestedData"/> document to the SQL Database as bytes using MessagePack
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compress properties and map property names to shorter names
|
||||
/// </summary>
|
||||
/// <param name="nestedData"></param>
|
||||
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<ContentNestedData>(data, _options);
|
||||
|
||||
public byte[] SerializeBytes(ContentNestedData nestedData) => MessagePackSerializer.Serialize(nestedData, _options);
|
||||
|
||||
@@ -7,14 +7,6 @@
|
||||
{
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Compress property data at the nucache SQL DB table level
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Only necessary if the document in the nucache SQL DB table isn't stored as compressed bytes
|
||||
/// </remarks>
|
||||
SQLDatabase = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Compress property data at the nucache BTree level
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user