feat(bot): add Redis cache

This commit is contained in:
spiral
2022-04-13 08:44:53 -04:00
parent fadf007abc
commit c2094e3b7a
9 changed files with 560 additions and 1 deletions

View File

@@ -44,7 +44,13 @@ public class BotModule: Module
}).AsSelf().SingleInstance();
builder.RegisterType<Cluster>().AsSelf().SingleInstance();
builder.RegisterType<RedisGatewayService>().AsSelf().SingleInstance();
builder.Register(c => { return new MemoryDiscordCache(); }).AsSelf().As<IDiscordCache>().SingleInstance();
builder.Register<IDiscordCache>(c => {
var botConfig = c.Resolve<BotConfig>();
if (botConfig.UseRedisCache)
return new RedisDiscordCache(c.Resolve<ILogger>());
return new MemoryDiscordCache();
}).AsSelf().SingleInstance();
builder.RegisterType<PrivateChannelService>().AsSelf().SingleInstance();
builder.Register(c =>