Skip to content

fix(Caching): Remove ITypeAliasProvider injection #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 20, 2022
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 @@ -16,7 +16,6 @@ public static IServiceCollection TryAddDistributedCacheCore(IServiceCollection s
=> serviceProvider.GetRequiredService<IDistributedCacheClientFactory>().Create());

services.TryAddSingleton<ITypeAliasFactory, DefaultTypeAliasFactory>();
services.TryAddSingleton<ITypeAliasProvider, DefaultTypeAliasProvider>();
services.Configure<TypeAliasFactoryOptions>(options => options.TryAdd(name));
return services;
}
Expand All @@ -29,7 +28,6 @@ public static IServiceCollection TryAddMultilevelCacheCore(IServiceCollection se
=> serviceProvider.GetRequiredService<IMultilevelCacheClientFactory>().Create());

services.TryAddSingleton<ITypeAliasFactory, DefaultTypeAliasFactory>();
services.TryAddSingleton<ITypeAliasProvider, DefaultTypeAliasProvider>();
services.Configure<TypeAliasFactoryOptions>(options => options.TryAdd(name));

TryAddDistributedCacheCore(services, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

// ReSharper disable once CheckNamespace

namespace Masa.BuildingBlocks.Caching;

public class DefaultTypeAliasProvider : ITypeAliasProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ internal static void UseStackExchangeRedisCache(
});
options.Options.Add(cacheRelationOptions);
});

services.TryAddSingleton<ITypeAliasFactory, DefaultTypeAliasFactory>();
services.TryAddSingleton<ITypeAliasProvider, DefaultTypeAliasProvider>();
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,14 @@
"GlobalCacheOptions": {
"CacheKeyType": 3
}
},
"RedisConfig": {
"Servers": [
{
"Host": "localhost",
"Port": 6379
}
],
"DefaultDatabase": 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

// ReSharper disable once CheckNamespace

using Microsoft.Extensions.Configuration;

namespace Microsoft.Extensions.DependencyInjection;

public static class ServiceCollectionExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
global using Masa.BuildingBlocks.Caching;
global using Masa.Contrib.Caching.MultilevelCache;
global using Microsoft.Extensions.Caching.Memory;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.Options;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

// ReSharper disable once CheckNamespace

namespace Masa.BuildingBlocks.Configuration;

public static class MasaConfigurationExtensions
Expand Down Expand Up @@ -35,6 +36,10 @@ public static IMasaConfigurationBuilder UseDcc(
null,
multilevelCacheOptions =>
{
multilevelCacheOptions.GlobalCacheOptions = new CacheOptions()
{
CacheKeyType = CacheKeyType.None
};
multilevelCacheOptions.SubscribeKeyType = SubscribeKeyType.SpecificPrefix;
multilevelCacheOptions.SubscribeKeyPrefix = dccOptions.SubscribeKeyPrefix ?? DEFAULT_SUBSCRIBE_KEY_PREFIX;
});
Expand Down