Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Masa.Contrib.Data.Mapping.Mapster;

public class DefaultMappingConfigProvider : IMappingConfigProvider
{
private readonly ConcurrentDictionary<(Type SourceType, Type DestinationType, MapOptions? MapOptions), TypeAdapterConfig?> _store = new();
private readonly MemoryCache<(Type SourceType, Type DestinationType, MapOptions? MapOptions), TypeAdapterConfig?> _cache = new();

private readonly MapOptions _options;

Expand All @@ -16,7 +16,7 @@ public TypeAdapterConfig GetConfig(Type sourceType, Type destinationType, MapOpt

protected virtual TypeAdapterConfig GetConfigByCache(Type sourceType, Type destinationType, MapOptions? options)
{
TypeAdapterConfig? config = _store.GetOrAdd(
TypeAdapterConfig? config = _cache.GetOrAdd(
(sourceType, destinationType, options),
type => GetAdapterConfig(type.SourceType, type.DestinationType, options));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

<ItemGroup>
<PackageReference Include="Mapster" Version="7.3.0" />
<PackageReference Include="Masa.Utils.Caching.Memory" Version="0.4.0-preview.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
global using Masa.BuildingBlocks.Data.Mapping.Options.Enum;
global using Masa.Contrib.Data.Mapping.Mapster.Internal;
global using Masa.Contrib.Data.Mapping.Mapster.Internal.Options;
global using Masa.Utils.Caching.Memory;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.DependencyInjection.Extensions;
global using System.Collections.Concurrent;
global using System.Linq.Expressions;
global using System.Reflection;