adds notes, ensures that we optimize property data when using msgpack binary serialization too!
This commit is contained in:
@@ -67,7 +67,8 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
pdata.Value = ReadObject(stream);
|
||||
|
||||
switch (map.CompressLevel)
|
||||
{
|
||||
{
|
||||
// If the property is compressed at either the DB or Nucache level, it means it's compressed here and we need to decompress
|
||||
case NucachePropertyCompressionLevel.SQLDatabase:
|
||||
case NucachePropertyCompressionLevel.NuCacheDatabase:
|
||||
if (!(pdata.Value is null) && pdata.Value is byte[] byteArrayValue)
|
||||
@@ -80,8 +81,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
break;
|
||||
case NucachePropertyDecompressionLevel.NotCompressed:
|
||||
//Shouldn't be any not compressed
|
||||
// TODO: Do we need to throw here?
|
||||
break;
|
||||
throw new InvalidOperationException($"{NucachePropertyDecompressionLevel.NotCompressed} cannot be a decompression option for property {alias} since it's compresion option is {map.CompressLevel}");
|
||||
case NucachePropertyDecompressionLevel.Immediate:
|
||||
default:
|
||||
pdata.Value = Encoding.UTF8.GetString(LZ4Pickler.Unpickle(byteArrayValue));
|
||||
|
||||
@@ -97,7 +97,12 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
|
||||
public ContentNestedData DeserializeBytes(byte[] data) => MessagePackSerializer.Deserialize<ContentNestedData>(data, _options);
|
||||
|
||||
public byte[] SerializeBytes(ContentNestedData nestedData) => MessagePackSerializer.Serialize(nestedData, _options);
|
||||
public byte[] SerializeBytes(ContentNestedData nestedData)
|
||||
{
|
||||
Optimize(nestedData);
|
||||
|
||||
return MessagePackSerializer.Serialize(nestedData, _options);
|
||||
}
|
||||
|
||||
//private class ContentNestedDataResolver : IFormatterResolver
|
||||
//{
|
||||
|
||||
@@ -16,6 +16,10 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
|
||||
private const char PrefixDouble = 'B';
|
||||
private const char PrefixDateTime = 'D';
|
||||
private const char PrefixByte = 'O';
|
||||
|
||||
// TODO: It might make sense to have another prefix for an LZ4 compressed byte array.
|
||||
// Would be an improvement for the SQLDatabase compression option because then you could mix compressed and decompressed properties with the same alias.
|
||||
// For example, don't compress recent content, but compress older content.
|
||||
private const char PrefixByteArray = 'A';
|
||||
|
||||
protected string ReadString(Stream stream) => PrimitiveSerializer.String.ReadFrom(stream);
|
||||
|
||||
Reference in New Issue
Block a user