Skip to content

Commit

Permalink
Revert "Better perf thanks to RecyclableMemoryStreamManager"
Browse files Browse the repository at this point in the history
This reverts commit f12a75c.
  • Loading branch information
jodydonetti committed May 19, 2024
1 parent 03009d1 commit ce1c02a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.IO;

namespace ZiggyCreatures.Caching.Fusion.Serialization.SystemTextJson;

Expand All @@ -10,8 +10,6 @@ namespace ZiggyCreatures.Caching.Fusion.Serialization.SystemTextJson;
public class FusionCacheSystemTextJsonSerializer
: IFusionCacheSerializer
{
private static readonly RecyclableMemoryStreamManager _manager = new RecyclableMemoryStreamManager();

/// <summary>
/// Create a new instance of a <see cref="FusionCacheSystemTextJsonSerializer"/> object.
/// </summary>
Expand All @@ -38,15 +36,15 @@ public byte[] Serialize<T>(T? obj)
/// <inheritdoc />
public async ValueTask<byte[]> SerializeAsync<T>(T? obj)
{
using var stream = _manager.GetStream();
using var stream = new MemoryStream();
await JsonSerializer.SerializeAsync<T?>(stream, obj, _options);
return stream.ToArray();
}

/// <inheritdoc />
public async ValueTask<T?> DeserializeAsync<T>(byte[] data)
{
using var stream = _manager.GetStream(data);
using var stream = new MemoryStream(data);
return await JsonSerializer.DeserializeAsync<T>(stream, _options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<RootNamespace>ZiggyCreatures.FusionCache.Serialization.SystemTextJson</RootNamespace>
<DocumentationFile>ZiggyCreatures.FusionCache.Serialization.SystemTextJson.xml</DocumentationFile>
<PackageReleaseNotes>
- Perf: better perf thanks to RecyclableMemoryStreamManager
- Updated: package dependencies
</PackageReleaseNotes>
</PropertyGroup>
Expand All @@ -24,7 +23,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="3.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.2" />
</ItemGroup>

Expand Down

0 comments on commit ce1c02a

Please sign in to comment.