Cache info about users, cleanup for module

This commit is contained in:
2022-01-03 23:25:20 +03:00
parent 64a4a1fabb
commit cf34fcd89a
2 changed files with 26 additions and 5 deletions
+5
View File
@@ -1,4 +1,5 @@
using BotFramework;
using Kruzya.TelegramBot.Core.Cache;
using Kruzya.TelegramBot.Core.Data;
using Kruzya.TelegramBot.Core.Extensions;
using Microsoft.AspNetCore.Builder;
@@ -7,6 +8,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Telegram.Bot.Types;
namespace Kruzya.TelegramBot.Core
{
@@ -36,6 +38,9 @@ namespace Kruzya.TelegramBot.Core
services.AddDbContext<CoreContext>(ctx =>
ctx.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
// Cache for users.
services.AddSingleton<ICacheStorage<long, User>, MemoryCache<long, User>>();
// Trigger module handlers.
_core.Modules.ConfigureServices(services);
}