move classes around, name caches more consistently, add more caches
This commit is contained in:
parent
e86b37ce2a
commit
e17dcf90a1
30 changed files with 443 additions and 51 deletions
|
|
@ -1,6 +1,8 @@
|
|||
using Catalogger.Backend.Bot.Commands;
|
||||
using Catalogger.Backend.Bot.Responders;
|
||||
using Catalogger.Backend.Cache;
|
||||
using Catalogger.Backend.Cache.InMemoryCache;
|
||||
using Catalogger.Backend.Cache.RedisCache;
|
||||
using Catalogger.Backend.Database;
|
||||
using Catalogger.Backend.Database.Queries;
|
||||
using Catalogger.Backend.Database.Redis;
|
||||
|
|
@ -65,27 +67,34 @@ public static class StartupExtensions
|
|||
|
||||
public static IServiceCollection AddCustomServices(this IServiceCollection services) => services
|
||||
.AddSingleton<IClock>(SystemClock.Instance)
|
||||
.AddSingleton<GuildCacheService>()
|
||||
.AddSingleton<RoleCacheService>()
|
||||
.AddSingleton<ChannelCacheService>()
|
||||
.AddSingleton<UserCacheService>()
|
||||
.AddSingleton<GuildCache>()
|
||||
.AddSingleton<RoleCache>()
|
||||
.AddSingleton<ChannelCache>()
|
||||
.AddSingleton<UserCache>()
|
||||
.AddSingleton<PluralkitApiService>()
|
||||
.AddScoped<IEncryptionService, EncryptionService>()
|
||||
.AddScoped<MessageRepository>()
|
||||
.AddSingleton<WebhookExecutorService>()
|
||||
.AddSingleton<PkMessageHandler>()
|
||||
.AddSingleton(InMemoryDataService<Snowflake, ChannelCommandData>.Instance)
|
||||
.AddHostedService<MetricsCollectionService>();
|
||||
.AddHostedService<MetricsCollectionService>()
|
||||
.AddSingleton<GuildFetchService>()
|
||||
.AddHostedService(serviceProvider => serviceProvider.GetRequiredService<GuildFetchService>());
|
||||
|
||||
public static IServiceCollection MaybeAddRedisCaches(this IServiceCollection services, Config config)
|
||||
{
|
||||
if (config.Database.Redis == null)
|
||||
{
|
||||
return services.AddSingleton<IWebhookCache, InMemoryWebhookCache>();
|
||||
return services
|
||||
.AddSingleton<IWebhookCache, InMemoryWebhookCache>()
|
||||
.AddSingleton<IMemberCache, InMemoryMemberCache>()
|
||||
.AddSingleton<IInviteCache, InMemoryInviteCache>();
|
||||
}
|
||||
|
||||
return services.AddSingleton<RedisService>()
|
||||
.AddScoped<IWebhookCache, RedisWebhookCache>();
|
||||
.AddSingleton<IWebhookCache, RedisWebhookCache>()
|
||||
.AddSingleton<IMemberCache, RedisMemberCache>()
|
||||
.AddSingleton<IInviteCache, RedisInviteCache>();
|
||||
}
|
||||
|
||||
public static async Task Initialize(this WebApplication app)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue